circular

package
v0.0.0-...-1c5d739 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 0 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

A Buffer is a fixed size buffer with Read and Write methods. When more than the allotted amount of data is written, the buffer will only retain the last size bytes of unread data. The zero value for Buffer is a buffer of size 0; all writes are discarded and there is never any data to read. This implementation is not thread-safe.

func NewBuffer

func NewBuffer(size int) *Buffer

NewBuffer returns a pointer to a Buffer with a maximum size of size.

func (*Buffer) IsEmpty

func (b *Buffer) IsEmpty() bool

IsEmpty will return true if the buffer is empty

func (*Buffer) IsFull

func (b *Buffer) IsFull() bool

IsFull will return true if the buffer is full

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (n int, err error)

Read reads up to len(p) bytes in to p; the actual number of bytes read is returned (n) along with any error condition.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

Write writes p[]byte to the buffer and returns the number of bytes written. Only the last b.size bytes are kept.

Jump to

Keyboard shortcuts

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