slice

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

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEFAULT_BUFFER_SIZE  int32 = 4 * 1024
	MINIMUM_CHUNK_SIZE   int32 = 1024
	OUTPUT_INSTANCE_SIZE int32 = util.SizeOf(&OutputStreamSliceOutput{})
)
View Source
var (
	EMPTY_SLICE   = &Slice{buf: make([]byte, 0), capacity: 0, readerMarker: -1, writerMarker: -1}
	INSTANCE_SIZE = int32(unsafe.Sizeof(EMPTY_SLICE))

	SLICE_KIND = reflect.TypeOf(EMPTY_SLICE).Kind()
)
View Source
var (
	BASIC_INSTANCE_SIZE int32 = util.SizeOf(&BasicSliceInput{})
)
View Source
var (
	// ChunkSize how much byte to allocate if there were not enough room
	ChunkSize = 1024
)

Global parameters, users can modify accordingly

View Source
var (
	DYNAMIC_INSTANCE_SIZE int32 = util.SizeOf(&DynamicSliceOutput{})
)
View Source
var (
	ErrOutOfBound = errors.New("index is out of bound")
)

Errors

Functions

func BytesHashCode

func BytesHashCode(b []byte) int32

func CheckPositionIndex

func CheckPositionIndex(index, size int64) int64

func CheckPositionIndex2

func CheckPositionIndex2(index, size int64, desc string) int64

func FindCRIterator

func FindCRIterator(b byte) bool

FindCRIterator find till \r

func FindCRLFIterator

func FindCRLFIterator(b byte) bool

FindCRLFIterator find till \r or \n

func FindLFIterator

func FindLFIterator(b byte) bool

FindLFIterator find till \n

func FindNotCRIterator

func FindNotCRIterator(b byte) bool

FindNotCRIterator find till not \r

func FindNotCRLFIterator

func FindNotCRLFIterator(b byte) bool

FindNotCRLFIterator find till not \r or \n

func FindNotLFIterator

func FindNotLFIterator(b byte) bool

FindNotLFIterator find till not \n

func FindNotNullIterator

func FindNotNullIterator(b byte) bool

FindNotNullIterator find till not null

func FindNotWhiteSpaceIterator

func FindNotWhiteSpaceIterator(b byte) bool

FindNotWhiteSpaceIterator fdin till \s \t \r\ n

func FindNullIterator

func FindNullIterator(b byte) bool

FindNullIterator find till null

func FindWhiteSpaceIterator

func FindWhiteSpaceIterator(b byte) bool

FindWhiteSpaceIterator fdin till \s \t \r\ n

Types

type BasicSliceInput

type BasicSliceInput struct {
	// 继承
	FixedLengthSliceInput
	// contains filtered or unexported fields
}

func final class BasicSliceInput

extends FixedLengthSliceInput

func NewBasicSliceInput

func NewBasicSliceInput(slice *Slice) *BasicSliceInput

func (*BasicSliceInput) Available

func (bt *BasicSliceInput) Available() int32

@Override

func (*BasicSliceInput) GetReader

func (bt *BasicSliceInput) GetReader() io.Reader

func (*BasicSliceInput) GetRetainedSize

func (bt *BasicSliceInput) GetRetainedSize() int64

@Override

func (*BasicSliceInput) IsReadable

func (bt *BasicSliceInput) IsReadable() bool

@Override

func (*BasicSliceInput) Length

func (bt *BasicSliceInput) Length() int64

@Override

func (*BasicSliceInput) Position

func (bt *BasicSliceInput) Position() int64

@Override

func (*BasicSliceInput) Read

func (bt *BasicSliceInput) Read(p []byte) (n int, err error)

func (*BasicSliceInput) ReadBS

func (bt *BasicSliceInput) ReadBS() (byte, error)

@Override

func (*BasicSliceInput) ReadBS2

func (bt *BasicSliceInput) ReadBS2(b []byte) (n int, err error)

func (*BasicSliceInput) ReadBS3

func (bt *BasicSliceInput) ReadBS3(destination []byte, destinationIndex int, length int) (n int, err error)

@Override

func (*BasicSliceInput) ReadBoolean

func (bt *BasicSliceInput) ReadBoolean() bool

@Override

func (*BasicSliceInput) ReadByte

func (bt *BasicSliceInput) ReadByte() byte

@Override

func (*BasicSliceInput) ReadBytes2

func (bt *BasicSliceInput) ReadBytes2(destination []byte, destinationIndex int32, length int32)

@Override

func (*BasicSliceInput) ReadDouble

func (bt *BasicSliceInput) ReadDouble() float64

@Override

func (*BasicSliceInput) ReadFloat

func (bt *BasicSliceInput) ReadFloat() float32

@Override

func (*BasicSliceInput) ReadInt

func (bt *BasicSliceInput) ReadInt() int32

@Override

func (*BasicSliceInput) ReadLong

func (bt *BasicSliceInput) ReadLong() int64

@Override

func (*BasicSliceInput) ReadOutputStream

func (bt *BasicSliceInput) ReadOutputStream(out mothio.OutputStream, length int32)

@Override

func (*BasicSliceInput) ReadShort

func (bt *BasicSliceInput) ReadShort() int16

@Override

func (*BasicSliceInput) ReadSlice

func (bt *BasicSliceInput) ReadSlice(length int32) *Slice

@Override

func (*BasicSliceInput) ReadSlice4

func (bt *BasicSliceInput) ReadSlice4(destination *Slice, destinationIndex int32, length int32)

@Override

func (*BasicSliceInput) ReadUnsignedByte

func (bt *BasicSliceInput) ReadUnsignedByte() uint8

@Override

func (*BasicSliceInput) ReadUnsignedShort

func (bt *BasicSliceInput) ReadUnsignedShort() uint16

@Override

func (*BasicSliceInput) Remaining

func (bt *BasicSliceInput) Remaining() int64

func (*BasicSliceInput) SetPosition

func (bt *BasicSliceInput) SetPosition(position int64)

@Override

func (*BasicSliceInput) Skip

func (bt *BasicSliceInput) Skip(length int64) int64

@Override

func (*BasicSliceInput) SkipBytes

func (bt *BasicSliceInput) SkipBytes(length int32) int32

@Override

func (*BasicSliceInput) Slice

func (bt *BasicSliceInput) Slice() *Slice

* * Returns a slice of this buffer's readable bytes. Modifying the content * of the returned buffer or this buffer affects each other's content * while they maintain separate indexes and marks. This method is * identical to {@code buf.slice(buf.position(), buf.available()())}. * This method does not modify {@code position} or {@code writerIndex} of * this buffer.

func (*BasicSliceInput) String

func (bt *BasicSliceInput) String() string

@Override

type ByteIterator

type ByteIterator func(byte) bool

ByteIterator type used for byte iteration

type DynamicSliceOutput

type DynamicSliceOutput struct {
	// 继承
	SliceOutput
	// contains filtered or unexported fields
}

func NewDynamicSliceOutput

func NewDynamicSliceOutput(estimatedSize int32) *DynamicSliceOutput

func (*DynamicSliceOutput) AppendByte

func (ct *DynamicSliceOutput) AppendByte(value byte) SliceOutput

@Override

func (*DynamicSliceOutput) AppendBytes

func (ct *DynamicSliceOutput) AppendBytes(source []byte, sourceIndex int32, length int32) SliceOutput

@Override

func (*DynamicSliceOutput) AppendBytes2

func (ct *DynamicSliceOutput) AppendBytes2(source []byte) SliceOutput

@Override

func (*DynamicSliceOutput) AppendDouble

func (ct *DynamicSliceOutput) AppendDouble(value float64) SliceOutput

@Override

func (*DynamicSliceOutput) AppendInt

func (ct *DynamicSliceOutput) AppendInt(value int32) SliceOutput

@Override

func (*DynamicSliceOutput) AppendLong

func (ct *DynamicSliceOutput) AppendLong(value int64) SliceOutput

@Override

func (*DynamicSliceOutput) AppendShort

func (ct *DynamicSliceOutput) AppendShort(value int16) SliceOutput

@Override

func (*DynamicSliceOutput) AppendSlice

func (ct *DynamicSliceOutput) AppendSlice(slice *Slice) SliceOutput

@Override

func (*DynamicSliceOutput) GetRetainedSize

func (ct *DynamicSliceOutput) GetRetainedSize() int64

@Override

func (*DynamicSliceOutput) GetUnderlyingSlice

func (ct *DynamicSliceOutput) GetUnderlyingSlice() *Slice

@Override

func (*DynamicSliceOutput) IsWritable

func (ct *DynamicSliceOutput) IsWritable() bool

@Override

func (*DynamicSliceOutput) Reset

func (ct *DynamicSliceOutput) Reset()

@Override

func (*DynamicSliceOutput) Reset2

func (ct *DynamicSliceOutput) Reset2(position int32)

@Override

func (*DynamicSliceOutput) Size

func (ct *DynamicSliceOutput) Size() int32

@Override

func (*DynamicSliceOutput) Slice

func (ct *DynamicSliceOutput) Slice() *Slice

@Override

func (*DynamicSliceOutput) String

func (ct *DynamicSliceOutput) String() string

@Override

func (*DynamicSliceOutput) ToString

func (ct *DynamicSliceOutput) ToString() string

@Override

func (*DynamicSliceOutput) WritableBytes

func (ct *DynamicSliceOutput) WritableBytes() int32

@Override

func (*DynamicSliceOutput) WriteBS

func (ct *DynamicSliceOutput) WriteBS(source []byte) (n int, err error)

func (*DynamicSliceOutput) WriteBS2

func (ct *DynamicSliceOutput) WriteBS2(b []byte, off int32, len int32) (n int, err error)

func (*DynamicSliceOutput) WriteByte

func (ct *DynamicSliceOutput) WriteByte(b byte) error

@Override

func (*DynamicSliceOutput) WriteBytes

func (ct *DynamicSliceOutput) WriteBytes(source []byte)

@Override

func (*DynamicSliceOutput) WriteBytes2

func (ct *DynamicSliceOutput) WriteBytes2(source []byte, sourceIndex int32, length int32)

@Override

func (*DynamicSliceOutput) WriteDouble

func (ct *DynamicSliceOutput) WriteDouble(value float64)

@Override

func (*DynamicSliceOutput) WriteFloat

func (ct *DynamicSliceOutput) WriteFloat(value float32)

@Override

func (*DynamicSliceOutput) WriteInputStream

func (ct *DynamicSliceOutput) WriteInputStream(input mothio.InputStream, length int32)

@Override

func (*DynamicSliceOutput) WriteInt

func (ct *DynamicSliceOutput) WriteInt(value int32)

@Override

func (*DynamicSliceOutput) WriteLong

func (ct *DynamicSliceOutput) WriteLong(value int64)

@Override

func (*DynamicSliceOutput) WriteShort

func (ct *DynamicSliceOutput) WriteShort(value int16)

@Override

func (*DynamicSliceOutput) WriteSlice

func (ct *DynamicSliceOutput) WriteSlice(source *Slice)

@Override

func (*DynamicSliceOutput) WriteSlice2

func (ct *DynamicSliceOutput) WriteSlice2(source *Slice, sourceIndex int32, length int32)

@Override

func (*DynamicSliceOutput) WriteZero

func (ct *DynamicSliceOutput) WriteZero(length int32)

@Override

type FixedLengthSliceInput

type FixedLengthSliceInput interface {
	// 继承
	SliceInput

	Length() int64
	Remaining() int64
}

type OutputStreamSliceOutput

type OutputStreamSliceOutput struct {
	// 继承
	SliceOutput
	// contains filtered or unexported fields
}

func NewOutputStreamSliceOutput

func NewOutputStreamSliceOutput(inputStream mothio.OutputStream) *OutputStreamSliceOutput

func NewOutputStreamSliceOutput2

func NewOutputStreamSliceOutput2(outputStream mothio.OutputStream, bufferSize int32) *OutputStreamSliceOutput

func (*OutputStreamSliceOutput) AppendByte

func (ot *OutputStreamSliceOutput) AppendByte(value byte) SliceOutput

@Override

func (*OutputStreamSliceOutput) AppendBytes

func (ot *OutputStreamSliceOutput) AppendBytes(source []byte, sourceIndex int32, length int32) SliceOutput

@Override

func (*OutputStreamSliceOutput) AppendBytes2

func (ot *OutputStreamSliceOutput) AppendBytes2(source []byte) SliceOutput

@Override

func (*OutputStreamSliceOutput) AppendDouble

func (ot *OutputStreamSliceOutput) AppendDouble(value float64) SliceOutput

@Override

func (*OutputStreamSliceOutput) AppendInt

func (ot *OutputStreamSliceOutput) AppendInt(value int32) SliceOutput

@Override

func (*OutputStreamSliceOutput) AppendLong

func (ot *OutputStreamSliceOutput) AppendLong(value int64) SliceOutput

@Override

func (*OutputStreamSliceOutput) AppendShort

func (ot *OutputStreamSliceOutput) AppendShort(value int16) SliceOutput

@Override

func (*OutputStreamSliceOutput) AppendSlice

func (ot *OutputStreamSliceOutput) AppendSlice(slice *Slice) SliceOutput

@Override

func (*OutputStreamSliceOutput) Close

func (ot *OutputStreamSliceOutput) Close() error

@Override

func (*OutputStreamSliceOutput) Flush

func (ot *OutputStreamSliceOutput) Flush()

@Override

func (*OutputStreamSliceOutput) GetRetainedSize

func (ot *OutputStreamSliceOutput) GetRetainedSize() int64

@Override

func (*OutputStreamSliceOutput) GetUnderlyingSlice

func (ot *OutputStreamSliceOutput) GetUnderlyingSlice() *Slice

@Override

func (*OutputStreamSliceOutput) IsWritable

func (ot *OutputStreamSliceOutput) IsWritable() bool

@Override

func (*OutputStreamSliceOutput) LongSize

func (ot *OutputStreamSliceOutput) LongSize() int64

func (*OutputStreamSliceOutput) Reset

func (ot *OutputStreamSliceOutput) Reset()

@Override

func (*OutputStreamSliceOutput) Reset2

func (ot *OutputStreamSliceOutput) Reset2(position int32)

@Override

func (*OutputStreamSliceOutput) Size

func (ot *OutputStreamSliceOutput) Size() int32

@Override

func (*OutputStreamSliceOutput) Slice

func (ot *OutputStreamSliceOutput) Slice() *Slice

@Override

func (*OutputStreamSliceOutput) String

func (ot *OutputStreamSliceOutput) String() string

@Override

func (*OutputStreamSliceOutput) ToString

func (ot *OutputStreamSliceOutput) ToString() string

@Override

func (*OutputStreamSliceOutput) WritableBytes

func (ot *OutputStreamSliceOutput) WritableBytes() int32

@Override

func (*OutputStreamSliceOutput) WriteB

func (ot *OutputStreamSliceOutput) WriteB(value byte) (n int, err error)

@Override

func (*OutputStreamSliceOutput) WriteBS

func (ot *OutputStreamSliceOutput) WriteBS(source []byte) (n int, err error)

@Override

func (*OutputStreamSliceOutput) WriteBS2

func (ot *OutputStreamSliceOutput) WriteBS2(source []byte, sourceIndex int32, length int32) (n int, err error)

@Override

func (*OutputStreamSliceOutput) WriteBoolean

func (ot *OutputStreamSliceOutput) WriteBoolean(value bool)

@Override

func (*OutputStreamSliceOutput) WriteByte

func (ot *OutputStreamSliceOutput) WriteByte(value byte) error

@Override

func (*OutputStreamSliceOutput) WriteBytes

func (ot *OutputStreamSliceOutput) WriteBytes(source []byte)

@Override

func (*OutputStreamSliceOutput) WriteBytes2

func (ot *OutputStreamSliceOutput) WriteBytes2(source []byte, sourceIndex int32, length int32)

@Override

func (*OutputStreamSliceOutput) WriteChar

func (ot *OutputStreamSliceOutput) WriteChar(value byte)

@Override

func (*OutputStreamSliceOutput) WriteChars

func (ot *OutputStreamSliceOutput) WriteChars(s string)

@Override

func (*OutputStreamSliceOutput) WriteDouble

func (ot *OutputStreamSliceOutput) WriteDouble(value float64)

@Override

func (*OutputStreamSliceOutput) WriteFloat

func (ot *OutputStreamSliceOutput) WriteFloat(value float32)

@Override

func (*OutputStreamSliceOutput) WriteInputStream

func (ot *OutputStreamSliceOutput) WriteInputStream(in mothio.InputStream, length int32)

@Override

func (*OutputStreamSliceOutput) WriteInt

func (ot *OutputStreamSliceOutput) WriteInt(value int32)

@Override

func (*OutputStreamSliceOutput) WriteLong

func (ot *OutputStreamSliceOutput) WriteLong(value int64)

@Override

func (*OutputStreamSliceOutput) WriteShort

func (ot *OutputStreamSliceOutput) WriteShort(value int16)

@Override

func (*OutputStreamSliceOutput) WriteSlice

func (ot *OutputStreamSliceOutput) WriteSlice(source *Slice)

@Override

func (*OutputStreamSliceOutput) WriteSlice2

func (ot *OutputStreamSliceOutput) WriteSlice2(source *Slice, sourceIndex int32, length int32)

@Override

func (*OutputStreamSliceOutput) WriteString

func (ot *OutputStreamSliceOutput) WriteString(s string)

@Override

func (*OutputStreamSliceOutput) WriteToOutputStream

func (ot *OutputStreamSliceOutput) WriteToOutputStream(source []byte, sourceIndex int32, length int32)

func (*OutputStreamSliceOutput) WriteToOutputStream2

func (ot *OutputStreamSliceOutput) WriteToOutputStream2(source *Slice, sourceIndex int32, length int32)

func (*OutputStreamSliceOutput) WriteZero

func (ot *OutputStreamSliceOutput) WriteZero(length int32)

@Override

type Slice

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

Slice Slice itself

func New

func New(size int, bufs ...[]byte) (*Slice, error)

NewSlice create new Slice, pass any []byte in as initial buffer, it will be auto capped

func NewBaseBuf

func NewBaseBuf(buf []byte) *Slice

*

*
*  基于buf做基础,buf 不做写入

func NewByString

func NewByString(s string) (*Slice, error)

func NewReader

func NewReader(reader io.Reader) (*Slice, error)

NewReader create Slice from io.Reader

func NewSlice

func NewSlice(bufs ...[]byte) (*Slice, error)

NewSlice create new Slice, pass any []byte in as initial buffer, it will be auto capped

func NewWithBuf

func NewWithBuf(buf []byte) *Slice

*

*
*  基于buf做基础,buf 做为写入

func NewWithSize

func NewWithSize(size int) *Slice

func NewWithString

func NewWithString(s string) *Slice

func (*Slice) AvailableBytes

func (b *Slice) AvailableBytes() []byte

AvailableBytes get available bytes([:size])

func (*Slice) Bytes

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

Bytes get all the bytes in buffer ([:capacity])

func (*Slice) Capacity

func (b *Slice) Capacity() int

Capacity get buffer capacity (how much it could read/write)

func (*Slice) CompareTo

func (b *Slice) CompareTo(ob *Slice) int

func (*Slice) CompareTo2

func (b *Slice) CompareTo2(offset int, length int, ob *Slice, otherOffset int, otherLength int) int

func (*Slice) Copy

func (b *Slice) Copy() *Slice

Copy deep copy to create an brand new Slice

func (*Slice) DiscardReadBytes

func (b *Slice) DiscardReadBytes()

DiscardReadBytes discard bytes that are read, adjust readerIndex/writerIndex accordingly

func (*Slice) EnsureCapacity

func (b *Slice) EnsureCapacity(size int)

EnsureCapacity allocate more bytes to ensure the capacity

func (*Slice) Equal

func (b *Slice) Equal(ob *Slice) bool

Equal if current Slice is equal to another Slice, compared by underlying byte slice

func (*Slice) Equal2

func (b *Slice) Equal2(offset int, ob *Slice, otherOffset int, length int) bool

Equal if current Slice is equal to another Slice, compared by underlying byte slice

func (*Slice) Flush

func (b *Slice) Flush()

Flush flush all bytes and reset indexes

func (*Slice) ForEachByte

func (b *Slice) ForEachByte(iterator ByteIterator, indexes ...int) int

ForEachByte iterate through readable bytes, ForEachByte(iterator, start), ForEachByte(iterator, start, end)

func (*Slice) ForceRelease

func (b *Slice) ForceRelease()

ForceRelease force release bufs

func (*Slice) FromReader

func (b *Slice) FromReader(reader io.Reader) error

ReadFrom read from io.reader

func (*Slice) GetBool

func (b *Slice) GetBool(i int) (bool, error)

GetBool get a bool at given position

func (*Slice) GetByte

func (b *Slice) GetByte(i int) (byte, error)

GetByte get a byte at given position

func (*Slice) GetByteInt32

func (b *Slice) GetByteInt32(i int32) byte

GetByte get a byte at given position

func (*Slice) GetBytes

func (b *Slice) GetBytes(p []byte, start int, indexes ...int) (int, error)

GetBytes get bytes at given position, GetBytes(p, start), GetBytes(p, start, end)

func (*Slice) GetFloat32BE

func (b *Slice) GetFloat32BE(i int) (float32, error)

GetFloat32BE get a float32 in big endian at given position

func (*Slice) GetFloat32LE

func (b *Slice) GetFloat32LE(i int) (float32, error)

GetFloat32LE get a float32 in little endian at given position

func (*Slice) GetFloat64BE

func (b *Slice) GetFloat64BE(i int) (float64, error)

GetFloat64BE get a float64 in big endian at given position

func (*Slice) GetFloat64LE

func (b *Slice) GetFloat64LE(i int) (float64, error)

GetFloat64LE get a float64 in little endian at given position

func (*Slice) GetInput

func (b *Slice) GetInput() *BasicSliceInput

func (*Slice) GetInt16BE

func (b *Slice) GetInt16BE(i int) (int16, error)

GetInt16BE get an int16 in big endian at given position

func (*Slice) GetInt16LE

func (b *Slice) GetInt16LE(i int) (int16, error)

GetInt16LE get an int16 in little endian at given position

func (*Slice) GetInt32BE

func (b *Slice) GetInt32BE(i int) (int32, error)

GetInt32BE get an int32 in big endian at given position

func (*Slice) GetInt32LE

func (b *Slice) GetInt32LE(i int) (int32, error)

GetInt32LE get an int32 in little endian at given position

func (*Slice) GetInt64BE

func (b *Slice) GetInt64BE(i int) (int64, error)

GetInt64BE get a int64 in big endian at given position

func (*Slice) GetInt64LE

func (b *Slice) GetInt64LE(i int) (int64, error)

GetInt64LE get a int64 in little endian at given position

func (*Slice) GetInt8

func (b *Slice) GetInt8(i int) (int8, error)

GetInt8 get an int8 at given position

func (*Slice) GetRetainedSize

func (s *Slice) GetRetainedSize() int32

func (*Slice) GetUInt16BE

func (b *Slice) GetUInt16BE(i int) (uint16, error)

GetUInt16BE get an uint16 in big endian at given position

func (*Slice) GetUInt16LE

func (b *Slice) GetUInt16LE(i int) (uint16, error)

GetUInt16LE get an uint16 in little endian at given position

func (*Slice) GetUInt32BE

func (b *Slice) GetUInt32BE(i int) (uint32, error)

GetUInt32BE get an uint32 in big endian at given position

func (*Slice) GetUInt32LE

func (b *Slice) GetUInt32LE(i int) (uint32, error)

GetUInt32LE get an uint32 in little endian at given position

func (*Slice) GetUInt64BE

func (b *Slice) GetUInt64BE(i int) (uint64, error)

GetUInt64BE get an uint64 in big endian at given position

func (*Slice) GetUInt64LE

func (b *Slice) GetUInt64LE(i int) (uint64, error)

GetUInt64LE get an uint64 in little endian at given position

func (*Slice) GetUInt8

func (b *Slice) GetUInt8(i int) (uint8, error)

GetUInt8 get an uint8 at given position

func (*Slice) HashCode

func (b *Slice) HashCode() int32

func (*Slice) HashCodeValue

func (b *Slice) HashCodeValue(offset int, length int) int32

func (*Slice) Index

func (b *Slice) Index(p []byte, indexes ...int) int

Index index a byte slice inside buffer, Index(p), Index(p, start), Index(p, start, end)

func (*Slice) IsCompact

func (b *Slice) IsCompact() bool

func (*Slice) IsReadable

func (b *Slice) IsReadable() bool

IsReadable if buf is readable (b.writerIndex > b.readerIndex)

func (*Slice) LenInt64

func (b *Slice) LenInt64() int64

Size get current written buffer size

func (*Slice) Length

func (b *Slice) Length() int32

Size get current written buffer size

func (*Slice) MakeSlice

func (b *Slice) MakeSlice(index int, length int) (*Slice, error)

func (*Slice) MarkReaderIndex

func (b *Slice) MarkReaderIndex()

MarkReaderIndex mark current reader index for reset in the future

func (*Slice) MarkWriterIndex

func (b *Slice) MarkWriterIndex()

MarkWriterIndex mark current writer index for reset in the future

func (*Slice) PutBool

func (b *Slice) PutBool(i int, val bool) error

PutBool put a bool at given position

func (*Slice) PutByte

func (b *Slice) PutByte(i int, val byte) error

PutByte put a byte at given position

func (*Slice) PutBytes

func (b *Slice) PutBytes(i int, p []byte) error

PutBytes put a bool at given position

func (*Slice) PutFloat32BE

func (b *Slice) PutFloat32BE(i int, val float32) error

PutFloat32BE put a float32 at given position in big endian

func (*Slice) PutFloat32LE

func (b *Slice) PutFloat32LE(i int, val float32) error

PutFloat32LE put a float32 at given position in little endian

func (*Slice) PutFloat64BE

func (b *Slice) PutFloat64BE(i int, val float64) error

PutFloat64BE put a float64 at given position in big endian

func (*Slice) PutFloat64LE

func (b *Slice) PutFloat64LE(i int, val float64) error

PutFloat64LE put a float64 at given position in little endian

func (*Slice) PutInt16BE

func (b *Slice) PutInt16BE(i int, val int16) error

PutInt16BE put an int16 at given position in big endian

func (*Slice) PutInt16LE

func (b *Slice) PutInt16LE(i int, val int16) error

PutInt16LE put an int16 at given position in little endian

func (*Slice) PutInt32BE

func (b *Slice) PutInt32BE(i int, val int32) error

PutInt32BE put an int32 at given position in big endian

func (*Slice) PutInt32LE

func (b *Slice) PutInt32LE(i int, val int32) error

PutInt32LE put an int32 at given position in little endian

func (*Slice) PutInt64BE

func (b *Slice) PutInt64BE(i int, val int64) error

PutInt64BE put an int64 at given position in big endian

func (*Slice) PutInt64LE

func (b *Slice) PutInt64LE(i int, val int64) error

PutInt64LE put an int64 at given position in little endian

func (*Slice) PutInt8

func (b *Slice) PutInt8(i int, val int8) error

PutInt8 put an int8 at given position

func (*Slice) PutUInt16BE

func (b *Slice) PutUInt16BE(i int, val uint16) error

PutUInt16BE put an uint16 at given position in big endian

func (*Slice) PutUInt16LE

func (b *Slice) PutUInt16LE(i int, val uint16) error

PutUInt16LE put an uint16 at given position in little endian

func (*Slice) PutUInt32BE

func (b *Slice) PutUInt32BE(i int, val uint32) error

PutUInt32BE put an uint32 at given position in big endian

func (*Slice) PutUInt32LE

func (b *Slice) PutUInt32LE(i int, val uint32) error

PutUInt32LE put an uint32 at given position in little endian

func (*Slice) PutUInt64BE

func (b *Slice) PutUInt64BE(i int, val uint64) error

PutUInt64BE put an uint64 at given position in big endian

func (*Slice) PutUInt64LE

func (b *Slice) PutUInt64LE(i int, val uint64) error

PutUInt64LE put an uint64 at given position in little endian

func (*Slice) PutUInt8

func (b *Slice) PutUInt8(i int, val uint8) error

PutUInt8 put an uint8 at given position

func (*Slice) Read

func (b *Slice) Read(p []byte) (int, error)

Read implements io.Reader

func (*Slice) ReadBool

func (b *Slice) ReadBool() (bool, error)

ReadBool read a bool

func (*Slice) ReadByte

func (b *Slice) ReadByte() (byte, error)

ReadByte read a byte

func (*Slice) ReadBytes

func (b *Slice) ReadBytes(p []byte) (int, error)

ReadBytes read bytes

func (*Slice) ReadFloat32BE

func (b *Slice) ReadFloat32BE() (float32, error)

ReadFloat32BE read a float32 in big endian

func (*Slice) ReadFloat32LE

func (b *Slice) ReadFloat32LE() (float32, error)

ReadFloat32LE read a float32 in little endian

func (*Slice) ReadFloat64BE

func (b *Slice) ReadFloat64BE() (float64, error)

ReadFloat64BE read a float64 in big endian

func (*Slice) ReadFloat64LE

func (b *Slice) ReadFloat64LE() (float64, error)

ReadFloat64LE read a float64 in little endian

func (*Slice) ReadInt16BE

func (b *Slice) ReadInt16BE() (int16, error)

ReadInt16BE read an int16 in big endian

func (*Slice) ReadInt16LE

func (b *Slice) ReadInt16LE() (int16, error)

ReadInt16LE read an int16 in little endian

func (*Slice) ReadInt32BE

func (b *Slice) ReadInt32BE() (int32, error)

ReadInt32BE read an int32 in big endian

func (*Slice) ReadInt32LE

func (b *Slice) ReadInt32LE() (int32, error)

ReadInt32LE read an int32 in little endian

func (*Slice) ReadInt64BE

func (b *Slice) ReadInt64BE() (int64, error)

ReadInt64BE read an int64 in big endian

func (*Slice) ReadInt64LE

func (b *Slice) ReadInt64LE() (int64, error)

ReadInt64LE read an int64 in little endian

func (*Slice) ReadInt8

func (b *Slice) ReadInt8() (int8, error)

ReadInt8 read an int8

func (*Slice) ReadSlice

func (b *Slice) ReadSlice(size int) (*Slice, error)

ReadSlice read bytes with given size into a new Slice

func (*Slice) ReadUInt16BE

func (b *Slice) ReadUInt16BE() (uint16, error)

ReadUInt16BE read a uint16 in big endian

func (*Slice) ReadUInt16LE

func (b *Slice) ReadUInt16LE() (uint16, error)

ReadUInt16LE read a uint16 in little endian

func (*Slice) ReadUInt32BE

func (b *Slice) ReadUInt32BE() (uint32, error)

ReadUInt32BE read a uint32 in big endian

func (*Slice) ReadUInt32LE

func (b *Slice) ReadUInt32LE() (uint32, error)

ReadUInt32LE read a uint32 in little endian

func (*Slice) ReadUInt64BE

func (b *Slice) ReadUInt64BE() (uint64, error)

ReadUInt64BE read a uint64 in big endian

func (*Slice) ReadUInt64LE

func (b *Slice) ReadUInt64LE() (uint64, error)

ReadUInt64LE read a uint64 in little endian

func (*Slice) ReadUInt8

func (b *Slice) ReadUInt8() (uint8, error)

ReadUInt8 read a uint8

func (*Slice) ReadableBytes

func (b *Slice) ReadableBytes() int

ReadableBytes how much bytes are there to be read

func (*Slice) ReaderIndex

func (b *Slice) ReaderIndex() int

ReaderIndex access current reader index

func (*Slice) Ref

func (b *Slice) Ref()

Ref increment reference counter

func (*Slice) Release

func (b *Slice) Release()

Release decrement reference counter, underlying buf will be cleared once reference count is 0

func (*Slice) ResetReaderIndex

func (b *Slice) ResetReaderIndex()

ResetReaderIndex reset reader index to marked index

func (*Slice) ResetWriterIndex

func (b *Slice) ResetWriterIndex()

ResetWriterIndex reset writer index to marked index

func (*Slice) Size

func (b *Slice) Size() int

Size get current written buffer size

func (*Slice) SizeInt32

func (b *Slice) SizeInt32() int32

func (*Slice) Skip

func (b *Slice) Skip(n int) (int, error)

func (*Slice) String

func (b *Slice) String() string

String buf to string

func (*Slice) ToWriter

func (b *Slice) ToWriter(writer io.Writer) error

WriteTo write to io.Writer

func (*Slice) UnsafeBytes

func (b *Slice) UnsafeBytes() []byte

UnsafeBytes DANGER! access underlying buffer directly

func (*Slice) Write

func (b *Slice) Write(p []byte) (int, error)

Write implements io.Writer

func (*Slice) WriteBool

func (b *Slice) WriteBool(val bool) error

WriteBool write a bool

func (*Slice) WriteByte

func (b *Slice) WriteByte(val byte) error

WriteByte write a byte

func (*Slice) WriteBytes

func (b *Slice) WriteBytes(p []byte) error

WriteBytes write bytes

func (*Slice) WriteFloat32BE

func (b *Slice) WriteFloat32BE(val float32) error

WriteFloat32BE write a float32 in big endian

func (*Slice) WriteFloat32LE

func (b *Slice) WriteFloat32LE(val float32) error

WriteFloat32LE write a float32 in little endian

func (*Slice) WriteFloat64BE

func (b *Slice) WriteFloat64BE(val float64) error

WriteFloat64BE write a float64 in big endian

func (*Slice) WriteFloat64LE

func (b *Slice) WriteFloat64LE(val float64) error

WriteFloat64LE write a float64 in little endian

func (*Slice) WriteInt16BE

func (b *Slice) WriteInt16BE(val int16) error

WriteInt16BE write an int16 in big endian

func (*Slice) WriteInt16LE

func (b *Slice) WriteInt16LE(val int16) error

WriteInt16LE write an int16 in little endian

func (*Slice) WriteInt32BE

func (b *Slice) WriteInt32BE(val int32) error

WriteInt32BE write an int32 in big endian

func (*Slice) WriteInt32LE

func (b *Slice) WriteInt32LE(val int32) error

WriteInt32LE write an int32 in little endian

func (*Slice) WriteInt64BE

func (b *Slice) WriteInt64BE(val int64) error

WriteInt64BE write an int64 in big endian

func (*Slice) WriteInt64LE

func (b *Slice) WriteInt64LE(val int64) error

WriteInt64LE write an int64 in little endian

func (*Slice) WriteInt8

func (b *Slice) WriteInt8(val int8) error

WriteInt8 write an int8

func (*Slice) WriteSlice

func (b *Slice) WriteSlice(slice *Slice, offset int, length int) error

func (*Slice) WriteUInt16BE

func (b *Slice) WriteUInt16BE(val uint16) error

WriteUInt16BE write an uint16 in big endian

func (*Slice) WriteUInt16LE

func (b *Slice) WriteUInt16LE(val uint16) error

WriteUInt16LE write an uint16 in little endian

func (*Slice) WriteUInt32BE

func (b *Slice) WriteUInt32BE(val uint32) error

WriteUInt32BE write an uint32 in big endian

func (*Slice) WriteUInt32LE

func (b *Slice) WriteUInt32LE(val uint32) error

WriteUInt32LE write an uint32 in little endian

func (*Slice) WriteUInt64BE

func (b *Slice) WriteUInt64BE(val uint64) error

WriteUInt64BE write an uint64 in big endian

func (*Slice) WriteUInt64LE

func (b *Slice) WriteUInt64LE(val uint64) error

WriteUInt64LE write an uint64 in little endian

func (*Slice) WriteUInt8

func (b *Slice) WriteUInt8(val uint8) error

WriteUInt8 write an uint8

func (*Slice) WriterIndex

func (b *Slice) WriterIndex() int

WriterIndex access current writer index

type SliceInput

type SliceInput interface {
	// 继承
	mothio.InputStream
	// 继承
	mothio.DataInput

	/**
	 * Returns the {@code position} of this buffer.
	 */
	Position() int64

	/**
	 * Sets the {@code position} of this buffer.
	 *
	 * @throws IndexOutOfBoundsException if the specified {@code position} is
	 * less than {@code 0} or
	 * greater than {@code this.writerIndex}
	 */
	SetPosition(position int64)

	/**
	 * Returns {@code true}
	 * if and only if {@code available()} is greater
	 * than {@code 0}.
	 */
	IsReadable() bool

	/**
	 * Returns the number of bytes that can be read without blocking.
	 */
	//@Override
	Available() int32

	//@Override
	ReadBS() (byte, error)

	/**
	 * Returns true if the byte at the current {@code position} is not {@code 0} and increases
	 * the {@code position} by {@code 1} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 1}
	 */
	//@Override
	ReadBoolean() bool

	/**
	 * Gets a byte at the current {@code position} and increases
	 * the {@code position} by {@code 1} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 1}
	 */
	//@Override
	ReadByte() byte

	/**
	 * Gets an unsigned byte at the current {@code position} and increases
	 * the {@code position} by {@code 1} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 1}
	 */
	//@Override
	ReadUnsignedByte() uint8

	/**
	 * Gets a 16-bit short integer at the current {@code position}
	 * and increases the {@code position} by {@code 2} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 2}
	 */
	//@Override
	ReadShort() int16

	/**
	 * Gets an unsigned 16-bit short integer at the current {@code position}
	 * and increases the {@code position} by {@code 2} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 2}
	 */
	//@Override
	ReadUnsignedShort() uint16

	/**
	 * Gets a 32-bit integer at the current {@code position}
	 * and increases the {@code position} by {@code 4} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 4}
	 */
	//@Override
	ReadInt() int32

	/**
	 * Gets an unsigned 32-bit integer at the current {@code position}
	 * and increases the {@code position} by {@code 4} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 4}
	 */
	ReadUnsignedInt() int64

	/**
	 * Gets a 64-bit long at the current {@code position}
	 * and increases the {@code position} by {@code 8} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 8}
	 */
	//@Override
	ReadLong() int64

	/**
	 * Gets a 32-bit float at the current {@code position}
	 * and increases the {@code position} by {@code 4} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 4}
	 */
	//@Override
	ReadFloat() float32

	/**
	 * Gets a 64-bit double at the current {@code position}
	 * and increases the {@code position} by {@code 8} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.available()} is less than {@code 8}
	 */
	//@Override
	ReadDouble() float64

	/**
	 * Returns a new slice of this buffer's sub-region starting at the current
	 * {@code position} and increases the {@code position} by the size
	 * of the new slice (= {@code length}).
	 *
	 * @param length the size of the new slice
	 * @return the newly created slice
	 * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.available()}
	 */
	ReadSlice(length int32) *Slice

	//@Override
	ReadFully(destination []byte)

	//@Override
	ReadBS2(b []byte) (n int, err error)

	//@Override
	ReadBS3(b []byte, off int, l int) (n int, err error)
	/**
	 * Transfers this buffer's data to the specified destination starting at
	 * the current {@code position} and increases the {@code position}
	 * by the number of the transferred bytes (= {@code dst.length}).
	 *
	 * @throws IndexOutOfBoundsException if {@code dst.length} is greater than {@code this.available()}
	 */
	ReadBytes(destination []byte)

	//@Override
	ReadFully2(destination []byte, offset int, length int)

	/**
	 * Transfers this buffer's data to the specified destination starting at
	 * the current {@code position} and increases the {@code position}
	 * by the number of the transferred bytes (= {@code length}).
	 *
	 * @param destinationIndex the first index of the destination
	 * @param length the number of bytes to transfer
	 * @throws IndexOutOfBoundsException if the specified {@code destinationIndex} is less than {@code 0},
	 * if {@code length} is greater than {@code this.available()}, or
	 * if {@code destinationIndex + length} is greater than {@code destination.length}
	 */
	ReadBytes2(destination []byte, destinationIndex int32, length int32)
	/**
	 * Transfers this buffer's data to the specified destination starting at
	 * the current {@code position} until the destination becomes
	 * non-writable, and increases the {@code position} by the number of the
	 * transferred bytes.  This method is basically same with
	 * {@link #readBytes(Slice, int, int)}, except that this method
	 * increases the {@code writerIndex} of the destination by the number of
	 * the transferred bytes while {@link #readBytes(Slice, int, int)}
	 * does not.
	 *
	 * @throws IndexOutOfBoundsException if {@code destination.writableBytes} is greater than
	 * {@code this.available()}
	 */
	ReadSlice2(destination *Slice)

	/**
	 * Transfers this buffer's data to the specified destination starting at
	 * the current {@code position} and increases the {@code position}
	 * by the number of the transferred bytes (= {@code length}).  This method
	 * is basically same with {@link #readBytes(Slice, int, int)},
	 * except that this method increases the {@code writerIndex} of the
	 * destination by the number of the transferred bytes (= {@code length})
	 * while {@link #readBytes(Slice, int, int)} does not.
	 *
	 * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.available()} or
	 * if {@code length} is greater than {@code destination.writableBytes}
	 */
	ReadSlice3(destination *Slice, length int32)

	/**
	 * Transfers this buffer's data to the specified destination starting at
	 * the current {@code position} and increases the {@code position}
	 * by the number of the transferred bytes (= {@code length}).
	 *
	 * @param destinationIndex the first index of the destination
	 * @param length the number of bytes to transfer
	 * @throws IndexOutOfBoundsException if the specified {@code destinationIndex} is less than {@code 0},
	 * if {@code length} is greater than {@code this.available()}, or
	 * if {@code destinationIndex + length} is greater than
	 * {@code destination.capacity}
	 */
	ReadSlice4(destination *Slice, destinationIndex int32, length int32)

	/**
	 * Transfers this buffer's data to the specified stream starting at the
	 * current {@code position}.
	 *
	 * @param length the number of bytes to transfer
	 * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.available()}
	 * @throws java.io.IOException if the specified stream threw an exception during I/O
	 */
	ReadOutputStream(out mothio.OutputStream, length int32)
	//@Override
	Skip(length int64) int64
	//@Override
	SkipBytes(length int32) int32
	//@Override
	Close()

	/**
	 * Approximate number of bytes retained by this instance.
	 */
	GetRetainedSize() int64

	//@Override
	Mark(readLimit int32)

	//@Override
	Reset()

	//@Override
	MarkSupported() bool

	//@Override
	ReadChar() int8

	//@Override
	ReadLine() string
}

type SliceOutput

type SliceOutput interface {
	// 继承
	mothio.OutputStream
	// 继承
	mothio.DataOutput

	/**
	 * Resets this stream to the initial position.
	 */
	Reset()
	/**
	 * Resets this stream to the specified position.
	 */
	Reset2(position int32)

	/**
	 * Returns the {@code writerIndex} of this buffer.
	 */
	Size() int32

	/**
	 * Approximate number of bytes retained by this.
	 */
	GetRetainedSize() int64

	/**
	 * Returns the number of writable bytes which is equal to
	 * {@code (this.capacity - this.writerIndex)}.
	 */
	WritableBytes() int32
	/**
	 * Returns {@code true}
	 * if and only if {@code (this.capacity - this.writerIndex)} is greater
	 * than {@code 0}.
	 */
	IsWritable() bool

	//@Override
	WriteBoolean(value bool)

	//@Override
	WriteB(value byte) (n int, err error)
	/**
	 * Sets the specified byte at the current {@code writerIndex}
	 * and increases the {@code writerIndex} by {@code 1} in this buffer.
	 * The 24 high-order bits of the specified value are ignored.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 1}
	 */
	//  @Override
	WriteByte(value byte) error

	/**
	 * Sets the specified 16-bit short integer at the current
	 * {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
	 * in this buffer.  The 16 high-order bits of the specified value are ignored.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 2}
	 */
	//  @Override
	WriteShort(value int16)

	/**
	 * Sets the specified 32-bit integer at the current {@code writerIndex}
	 * and increases the {@code writerIndex} by {@code 4} in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 4}
	 */
	//  @Override
	WriteInt(value int32)

	/**
	 * Sets the specified 64-bit long integer at the current
	 * {@code writerIndex} and increases the {@code writerIndex} by {@code 8}
	 * in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 8}
	 */
	//  @Override
	WriteLong(value int64)

	/**
	 * Sets the specified 32-bit float at the current
	 * {@code writerIndex} and increases the {@code writerIndex} by {@code 4}
	 * in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 4}
	 */
	//  @Override
	WriteFloat(v float32)

	/**
	 * Sets the specified 64-bit double at the current
	 * {@code writerIndex} and increases the {@code writerIndex} by {@code 8}
	 * in this buffer.
	 *
	 * @throws IndexOutOfBoundsException if {@code this.writableBytes} is less than {@code 8}
	 */
	//  @Override
	WriteDouble(value float64)

	/**
	 * Transfers the specified source buffer's data to this buffer starting at
	 * the current {@code writerIndex} until the source buffer becomes
	 * unreadable, and increases the {@code writerIndex} by the number of
	 * the transferred bytes.  This method is basically same with
	 * {@link #writeBytes(Slice, int, int)}, except that this method
	 * increases the {@code readerIndex} of the source buffer by the number of
	 * the transferred bytes while {@link #writeBytes(Slice, int, int)}
	 * does not.
	 *
	 * @throws IndexOutOfBoundsException if {@code source.readableBytes} is greater than {@code this.writableBytes}
	 */
	WriteSlice(source *Slice)

	WriteSlice2(source *Slice, sourceIndex int32, length int32)

	//@Override
	WriteBS(source []byte) (n int, err error)

	WriteBytes(source []byte)

	//@Override
	WriteBS2(source []byte, sourceIndex int32, length int32) (n int, err error)

	WriteBytes2(source []byte, sourceIndex int32, length int32)

	/**
	 * Transfers the content of the specified stream to this buffer
	 * starting at the current {@code writerIndex} and increases the
	 * {@code writerIndex} by the number of the transferred bytes.
	 *
	 * @param length the number of bytes to transfer
	 * @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.writableBytes}
	 * @throws java.io.IOException if the specified stream threw an exception during I/O
	 */
	WriteInputStream(in mothio.InputStream, length int32)

	WriteZero(length int32)

	// abstract
	Slice() *Slice

	/**
	 * Returns the raw underlying slice of this output stream.  The slice may
	 * be larger than the size of this stream.
	 */
	GetUnderlyingSlice() *Slice

	/**
	 * Decodes this buffer's readable bytes into a string with the specified
	 * character set name.  This method is identical to
	 * {@code buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName)}.
	 * This method does not modify {@code readerIndex} or {@code writerIndex} of
	 * this buffer.
	 */
	ToString() string

	AppendLong(value int64) SliceOutput

	AppendDouble(value float64) SliceOutput

	AppendInt(value int32) SliceOutput

	AppendShort(value int16) SliceOutput

	AppendByte(value byte) SliceOutput

	AppendBytes(source []byte, sourceIndex int32, length int32) SliceOutput

	AppendBytes2(source []byte) SliceOutput

	AppendSlice(slice *Slice) SliceOutput

	//@Override
	WriteChar(value byte)

	//@Override
	WriteChars(s string)

	//@Override
	WriteString(s string)
}

abstract

Jump to

Keyboard shortcuts

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