collections

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitArray

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

BitArray is a simple struct for maintaining state of a bit array, which is useful for tracking bool type values efficiently. Not thread-safe.

func NewBitArray

func NewBitArray(buf []byte) *BitArray

NewBitArray returns a new BitArray from buf.

func (*BitArray) Bytes

func (ba *BitArray) Bytes() []byte

Bytes return the underlying bytes slice

func (*BitArray) GetBit

func (ba *BitArray) GetBit(k uint16) bool

GetBit returns a bool which indicates given index has been set before.

func (*BitArray) Len

func (ba *BitArray) Len() int

Len returns the length of the bit-array.

func (*BitArray) Reset

func (ba *BitArray) Reset(buf []byte)

Reset resets all payload to zero.

func (*BitArray) SetBit

func (ba *BitArray) SetBit(k uint16)

SetBit sets a bit at the given index.

func (*BitArray) String

func (ba *BitArray) String() string

String implements stringer.

type FloatArray

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

FloatArray encapsulates methods for using the float array support mark pos if it has value

func NewFloatArray

func NewFloatArray(capacity int) *FloatArray

NewFloatArray creates a float array with a certain capacity

func (*FloatArray) Capacity

func (f *FloatArray) Capacity() int

Capacity returns the capacity of array

func (*FloatArray) GetValue

func (f *FloatArray) GetValue(pos int) float64

GetValue returns value with pos, if it has not value return 0

func (*FloatArray) HasValue

func (f *FloatArray) HasValue(pos int) bool

HasValue returns if has value with pos

func (*FloatArray) IsEmpty

func (f *FloatArray) IsEmpty() bool

IsEmpty tests if array is empty

func (*FloatArray) IsSingle

func (f *FloatArray) IsSingle() bool

IsSingle return if is single value

func (*FloatArray) Marks

func (f *FloatArray) Marks() []uint8

Marks returns the marks of array

func (*FloatArray) NewIterator

func (f *FloatArray) NewIterator() *FloatArrayIterator

NewIterator returns an iterator over the array

func (*FloatArray) Reset

func (f *FloatArray) Reset()

Reset resets all values and mark for reusing

func (*FloatArray) SetSingle

func (f *FloatArray) SetSingle(single bool)

SetSingle sets is array is single value, mean all values is same

func (*FloatArray) SetValue

func (f *FloatArray) SetValue(pos int, value float64)

SetValue sets value with pos, if pos out of bounds, return it

func (*FloatArray) Size

func (f *FloatArray) Size() int

Size returns size of array

type FloatArrayIterator

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

FloatArrayIterator represents a float array iterator

func (*FloatArrayIterator) HasNext

func (it *FloatArrayIterator) HasNext() bool

HasNext returns if this iterator has more values

func (*FloatArrayIterator) Next

func (it *FloatArrayIterator) Next() (idx int, value float64)

Next returns the next value and index

type Stack

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

Stack represents a last-in-first-out(LIFO) stack of interface, using slice saving data. NOTICE: not safe for goroutine concurrent

func NewStack

func NewStack() *Stack

NewStack creates an empty stack

func (*Stack) Empty

func (s *Stack) Empty() bool

Empty tests if this stack is empty

func (*Stack) Peek

func (s *Stack) Peek() interface{}

Peek looks at the element at the top of this stack without removing it from the stack

func (*Stack) Pop

func (s *Stack) Pop() interface{}

Pop removes the element at the top of this stack, if stack is empty return nil

func (*Stack) Push

func (s *Stack) Push(element interface{})

Push pushes an element onto the top of this stack

func (*Stack) Size

func (s *Stack) Size() int

Size returns the number of elements in the stack

Jump to

Keyboard shortcuts

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