alloc

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Value []byte
	// contains filtered or unexported fields
}

Buffer is a recyclable allocation of a byte array. Buffer.Release() recycles the buffer into an internal buffer pool, in order to recreate a buffer more quickly.

func NewBuffer

func NewBuffer() *Buffer

NewBuffer creates a Buffer with 8K bytes of arbitrary content.

func NewLargeBuffer

func NewLargeBuffer() *Buffer

NewLargeBuffer creates a Buffer with 64K bytes of arbitrary content.

func NewSmallBuffer

func NewSmallBuffer() *Buffer

NewSmallBuffer creates a Buffer with 1K bytes of arbitrary content.

func (*Buffer) Append

func (b *Buffer) Append(data []byte) *Buffer

Append appends a byte array to the end of the buffer.

func (*Buffer) AppendBytes

func (b *Buffer) AppendBytes(bytes ...byte) *Buffer

AppendBytes appends one or more bytes to the end of the buffer.

func (*Buffer) Bytes added in v1.9.1

func (b *Buffer) Bytes() []byte

Bytes returns the content bytes of this Buffer.

func (*Buffer) Clear

func (b *Buffer) Clear() *Buffer

Clear clears the content of the buffer, results an empty buffer with Len() = 0.

func (*Buffer) FillFrom added in v1.9.1

func (b *Buffer) FillFrom(reader io.Reader) (int, error)

func (*Buffer) IsEmpty added in v1.9.1

func (b *Buffer) IsEmpty() bool

func (*Buffer) IsFull

func (b *Buffer) IsFull() bool

IsFull returns true if the buffer has no more room to grow.

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the length of the buffer content.

func (*Buffer) Prepend added in v1.9.1

func (b *Buffer) Prepend(data []byte) *Buffer

Prepend prepends bytes in front of the buffer. Caller must ensure total bytes prepended is no more than 16 bytes.

func (*Buffer) Read added in v1.9.1

func (b *Buffer) Read(data []byte) (int, error)

Read implements io.Reader.Read().

func (*Buffer) Release

func (b *Buffer) Release()

Release recycles the buffer into an internal buffer pool.

func (*Buffer) Slice

func (b *Buffer) Slice(from, to int) *Buffer

Slice cuts the buffer at the given position.

func (*Buffer) SliceBack added in v1.9.1

func (b *Buffer) SliceBack(offset int) *Buffer

SliceBack extends the Buffer to its front by offset bytes. Caller must ensure cumulated offset is no more than 16.

func (*Buffer) SliceFrom

func (b *Buffer) SliceFrom(from int) *Buffer

SliceFrom cuts the buffer at the given position.

func (*Buffer) Write

func (b *Buffer) Write(data []byte) (int, error)

Write implements Write method in io.Writer.

Jump to

Keyboard shortcuts

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