Documentation ¶
Index ¶
- Variables
- type RingBuffer
- func (r *RingBuffer) Bytes() (buf []byte)
- func (r *RingBuffer) Capacity() int
- func (r *RingBuffer) IsEmpty() bool
- func (r *RingBuffer) IsFull() bool
- func (r *RingBuffer) Length() int
- func (r *RingBuffer) Peek(len int) (first []byte, end []byte)
- func (r *RingBuffer) PeekAll() (first []byte, end []byte)
- func (r *RingBuffer) PeekUint16() uint16
- func (r *RingBuffer) PeekUint32() uint32
- func (r *RingBuffer) PeekUint64() uint64
- func (r *RingBuffer) PeekUint8() uint8
- func (r *RingBuffer) Read(p []byte) (n int, err error)
- func (r *RingBuffer) ReadByte() (b byte, err error)
- func (r *RingBuffer) Reset()
- func (r *RingBuffer) Retrieve(len int)
- func (r *RingBuffer) RetrieveAll()
- func (r *RingBuffer) String() string
- func (r *RingBuffer) VirtualFlush()
- func (r *RingBuffer) VirtualLength() int
- func (r *RingBuffer) VirtualRead(p []byte) (n int, err error)
- func (r *RingBuffer) VirtualRevert()
- func (r *RingBuffer) Write(p []byte) (n int, err error)
- func (r *RingBuffer) WriteByte(c byte) error
- func (r *RingBuffer) WriteString(s string) (n int, err error)
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 NewWithData ¶
func NewWithData(data []byte) *RingBuffer
NewWithData:特殊场景使用,RingBuffer 会持有data,不会自己申请内存去拷贝
func (*RingBuffer) Bytes ¶
func (r *RingBuffer) Bytes() (buf []byte)
Bytes:返回所有可读数据,此操作不会移动读指针,仅仅是拷贝全部数据
func (*RingBuffer) IsEmpty ¶
func (r *RingBuffer) IsEmpty() bool
func (*RingBuffer) IsFull ¶
func (r *RingBuffer) IsFull() bool
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) 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) WriteString ¶
func (r *RingBuffer) WriteString(s string) (n int, err error)
WriteString:写入字符串
Click to show internal directories.
Click to hide internal directories.