ringbuffer

package
v0.0.0-...-14c233f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIsEmpty = errors.New("ring buffer is empty")

ErrIsEmpty:缓冲区为空错误

Functions

This section is empty.

Types

type RingBuffer

type RingBuffer struct {
	// contains filtered or unexported fields
}

RingBuffer:自动扩容循环缓冲区

func New

func New(size int) *RingBuffer

New:返回一个初始大小为 size 的 RingBuffer

func NewWithData

func NewWithData(data []byte) *RingBuffer

NewWithData:特殊场景使用,RingBuffer 会持有data,不会自己申请内存去拷贝

func (*RingBuffer) Bytes

func (r *RingBuffer) Bytes() (buf []byte)

Bytes:返回所有可读数据,此操作不会移动读指针,仅仅是拷贝全部数据

func (*RingBuffer) Capacity

func (r *RingBuffer) Capacity() int

Capacity:返回容量

func (*RingBuffer) IsEmpty

func (r *RingBuffer) IsEmpty() bool

func (*RingBuffer) IsFull

func (r *RingBuffer) IsFull() bool

func (*RingBuffer) Length

func (r *RingBuffer) Length() int

Length:返回长度

func (*RingBuffer) Peek

func (r *RingBuffer) Peek(len int) (first []byte, end []byte)

func (*RingBuffer) PeekAll

func (r *RingBuffer) PeekAll() (first []byte, end []byte)

func (*RingBuffer) PeekUint16

func (r *RingBuffer) PeekUint16() uint16

func (*RingBuffer) PeekUint32

func (r *RingBuffer) PeekUint32() uint32

func (*RingBuffer) PeekUint64

func (r *RingBuffer) PeekUint64() uint64

func (*RingBuffer) PeekUint8

func (r *RingBuffer) PeekUint8() uint8

func (*RingBuffer) Read

func (r *RingBuffer) Read(p []byte) (n int, err error)

func (*RingBuffer) ReadByte

func (r *RingBuffer) ReadByte() (b byte, err error)

ReadByte:进行 Byte 读取

func (*RingBuffer) Reset

func (r *RingBuffer) Reset()

func (*RingBuffer) Retrieve

func (r *RingBuffer) Retrieve(len int)

func (*RingBuffer) RetrieveAll

func (r *RingBuffer) RetrieveAll()

func (*RingBuffer) String

func (r *RingBuffer) String() string

func (*RingBuffer) VirtualFlush

func (r *RingBuffer) VirtualFlush()

VirtualFlush:刷新虚读指针 VirtualXXX 系列配合使用

func (*RingBuffer) VirtualLength

func (r *RingBuffer) VirtualLength() int

VirtualLength:虚拟长度,虚读后剩余可读数据长度 VirtualXXX 系列配合使用

func (*RingBuffer) VirtualRead

func (r *RingBuffer) VirtualRead(p []byte) (n int, err error)

VirtualRead:虚读,不移动 read 指针,需要配合 VirtualFlush 和 VirtualRevert 使用 VirtualXXX 系列配合使用

func (*RingBuffer) VirtualRevert

func (r *RingBuffer) VirtualRevert()

VirtualRevert:还原虚读指针 VirtualXXX 系列配合使用

func (*RingBuffer) Write

func (r *RingBuffer) Write(p []byte) (n int, err error)

Write:写 []byte 数据

func (*RingBuffer) WriteByte

func (r *RingBuffer) WriteByte(c byte) error

WriteByte:写 byte 数据

func (*RingBuffer) WriteString

func (r *RingBuffer) WriteString(s string) (n int, err error)

WriteString:写入字符串

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL