collections

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: BSD-2-Clause Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilData = errors.New("nil data")
View Source
var ErrShortRead = errors.New("short read")

Functions

This section is empty.

Types

type ArrayList

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

func NewArrayList

func NewArrayList() *ArrayList

func (*ArrayList) Add

func (this *ArrayList) Add(data ...interface{}) bool

func (*ArrayList) AsSlice

func (this *ArrayList) AsSlice() interface{}

func (*ArrayList) Clear

func (this *ArrayList) Clear()

func (*ArrayList) Clone

func (this *ArrayList) Clone() interface{}

func (*ArrayList) Contains

func (this *ArrayList) Contains(value interface{}) bool

func (*ArrayList) Delete

func (this *ArrayList) Delete(value interface{}) bool

func (*ArrayList) DeleteAt

func (this *ArrayList) DeleteAt(pos int) bool

func (*ArrayList) Elements

func (this *ArrayList) Elements() []interface{}

func (*ArrayList) Enumerator

func (this *ArrayList) Enumerator() Enumerator

returns a function that in every call return the next value and a flag to see if a value was retrived, even if it was nil

func (*ArrayList) Equals

func (this *ArrayList) Equals(e interface{}) bool

func (*ArrayList) Find

func (this *ArrayList) Find(value interface{}) (int, interface{})

func (*ArrayList) Get

func (this *ArrayList) Get(pos int) interface{}

func (*ArrayList) HashCode

func (this *ArrayList) HashCode() int

func (*ArrayList) Set

func (this *ArrayList) Set(pos int, value interface{})

func (*ArrayList) Size

func (this *ArrayList) Size() int

func (*ArrayList) Sort

func (this *ArrayList) Sort(less func(a, b interface{}) bool) []interface{}

func (*ArrayList) String

func (this *ArrayList) String() string

type ArrayListEnumerator

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

func (*ArrayListEnumerator) HasNext

func (this *ArrayListEnumerator) HasNext() bool

func (*ArrayListEnumerator) Next

func (this *ArrayListEnumerator) Next() interface{}

func (*ArrayListEnumerator) Peek

func (this *ArrayListEnumerator) Peek() interface{}

func (*ArrayListEnumerator) Remove

func (this *ArrayListEnumerator) Remove()

type BigFifo

type BigFifo struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewBigFifo

func NewBigFifo(threshold int, dir string, fileCap int64, codec tk.Codec, zero interface{}) (*BigFifo, error)

NewBigFifo creates a FIFO that after a certain number of elements will use disk files to store the elements.

threshold: buffer size. number after which will store to disk. dir: directory where the files will be created. codec: codec to convert between []byte and interface{} zero: zero data type

func (*BigFifo) Clear

func (this *BigFifo) Clear() error

func (*BigFifo) Close

func (this *BigFifo) Close() error

func (*BigFifo) Peek

func (this *BigFifo) Peek() interface{}

Peek returns the next element. When we consume it it might be different

func (*BigFifo) Popper

func (this *BigFifo) Popper() <-chan interface{}

Popper returns the channel element.

func (*BigFifo) Push

func (this *BigFifo) Push(value interface{}) error

func (*BigFifo) Size

func (this *BigFifo) Size() int64

type Collection

type Collection interface {
	Base

	Size() int
	Clear()
	Contains(value interface{}) bool
	Add(data ...interface{}) bool
	Delete(key interface{}) bool

	Enumerator() Enumerator
	Elements() []interface{}
	AsSlice() interface{} // returns elements in an array. ex: []int
	Sort(greater func(a, b interface{}) bool) []interface{}
}

type Enumerator

type Enumerator interface {
	HasNext() bool
	Next() interface{}
	Peek() interface{}
	Remove()
}

type Fifo

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

the Idea is to have a FIFO with a windowing (circular) feature. If the max size is reached, the oldest element will be removed.

func NewFifo

func NewFifo(capacity int) *Fifo

func NewLockFifo

func NewLockFifo(capacity int) *Fifo

NewLockFifo creates a Queue to be accessed concurrently

func (*Fifo) Clear

func (this *Fifo) Clear()

Clear resets the queue.

func (*Fifo) Peek

func (this *Fifo) Peek() interface{}

Peek returns the tail element without removing it.

func (*Fifo) Pop

func (this *Fifo) Pop() interface{}

Pop returns the tail element removing it.

func (*Fifo) Push

func (this *Fifo) Push(value interface{}) interface{}

Push adds an element to the head of the fifo. If the capacity was exceeded returns the element that had to be pushed out, otherwise returns nil.

func (*Fifo) Size

func (this *Fifo) Size() int

type FileFifo

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

FileFifo stores stores all data to disk.

func NewFileFifo

func NewFileFifo(dir string, fileCap int64) (*FileFifo, error)

NewFileFifo creates a FIFO supported by files. The supporting files will have a max size. Whenever that size is exceeded, a new file will be created. When all elements of a file are consumed (Pop) that file will be deleted.

FileFifo is not safe for concurrent access.

func (*FileFifo) Clear

func (this *FileFifo) Clear() error

func (*FileFifo) Peek

func (this *FileFifo) Peek() ([]byte, error)

func (*FileFifo) Pop

func (this *FileFifo) Pop() ([]byte, error)

func (*FileFifo) Push

func (this *FileFifo) Push(data []byte) error

func (*FileFifo) Size

func (this *FileFifo) Size() int64

type HashMap

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

func NewHashMap

func NewHashMap() *HashMap

func (*HashMap) Clear

func (this *HashMap) Clear()

func (*HashMap) Clone

func (this *HashMap) Clone() interface{}

func (*HashMap) Delete

func (this *HashMap) Delete(key Hasher) interface{}

func (*HashMap) Elements

func (this *HashMap) Elements() []*KeyValue

func (*HashMap) Equals

func (this *HashMap) Equals(e interface{}) bool

func (*HashMap) Get

func (this *HashMap) Get(key Hasher) (interface{}, bool)

func (*HashMap) HashCode

func (this *HashMap) HashCode() int

func (*HashMap) Iterator

func (this *HashMap) Iterator() Iterator

returns a function that in every call return the next value if key is null, no value was retrieved

func (*HashMap) Put

func (this *HashMap) Put(key Hasher, value interface{}) interface{}

func (*HashMap) Size

func (this *HashMap) Size() int

func (*HashMap) String

func (this *HashMap) String() string

func (*HashMap) Values

func (this *HashMap) Values() []interface{}

type HashMapIterator

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

func (*HashMapIterator) HasNext

func (this *HashMapIterator) HasNext() bool

func (*HashMapIterator) Next

func (this *HashMapIterator) Next() *KeyValue

func (*HashMapIterator) Peek

func (this *HashMapIterator) Peek() *KeyValue

func (*HashMapIterator) Remove

func (this *HashMapIterator) Remove()

type HashSet

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

func NewHashSet

func NewHashSet() *HashSet

func (*HashSet) Add

func (this *HashSet) Add(data ...interface{}) bool

func (*HashSet) AsSlice

func (this *HashSet) AsSlice() interface{}

func (*HashSet) Clear

func (this *HashSet) Clear()

func (*HashSet) Clone

func (this *HashSet) Clone() interface{}

func (*HashSet) Contains

func (this *HashSet) Contains(value interface{}) bool

func (*HashSet) Delete

func (this *HashSet) Delete(value interface{}) bool

func (*HashSet) Elements

func (this *HashSet) Elements() []interface{}

func (*HashSet) Enumerator

func (this *HashSet) Enumerator() Enumerator

returns a function that in every call return the next value if no value was retrived

func (*HashSet) Equals

func (this *HashSet) Equals(e interface{}) bool

func (*HashSet) HashCode

func (this *HashSet) HashCode() int

func (*HashSet) Size

func (this *HashSet) Size() int

func (*HashSet) Sort

func (this *HashSet) Sort(less func(a, b interface{}) bool) []interface{}

func (*HashSet) String

func (this *HashSet) String() string

type HashSetEnumerator

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

func (*HashSetEnumerator) HasNext

func (this *HashSetEnumerator) HasNext() bool

func (*HashSetEnumerator) Next

func (this *HashSetEnumerator) Next() interface{}

func (*HashSetEnumerator) Peek

func (this *HashSetEnumerator) Peek() interface{}

func (*HashSetEnumerator) Remove

func (this *HashSetEnumerator) Remove()

type IList

type IList interface {
	Collection

	Get(pos int) interface{}
	Set(pos int, value interface{})
	Find(value interface{}) (int, interface{})
	DeleteAt(pos int) bool
}

type Iterator

type Iterator interface {
	HasNext() bool
	Next() *KeyValue
	Peek() *KeyValue
	Remove()
}

type KeyValue

type KeyValue struct {
	Key   Hasher
	Value interface{}
}

func (*KeyValue) Equals

func (this *KeyValue) Equals(e interface{}) bool

func (*KeyValue) HashCode

func (this *KeyValue) HashCode() int

func (*KeyValue) String

func (this *KeyValue) String() string

type LinkedHashMap

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

func NewLinkedHashMap

func NewLinkedHashMap() *LinkedHashMap

func (*LinkedHashMap) Clear

func (this *LinkedHashMap) Clear()

func (*LinkedHashMap) Clone

func (this *LinkedHashMap) Clone() interface{}

func (*LinkedHashMap) Delete

func (this *LinkedHashMap) Delete(key Hasher) interface{}

func (*LinkedHashMap) Elements

func (this *LinkedHashMap) Elements() []*KeyValue

func (*LinkedHashMap) Equals

func (this *LinkedHashMap) Equals(e interface{}) bool

func (*LinkedHashMap) Get

func (this *LinkedHashMap) Get(key Hasher) (interface{}, bool)

func (*LinkedHashMap) HashCode

func (this *LinkedHashMap) HashCode() int

func (*LinkedHashMap) Iterator

func (this *LinkedHashMap) Iterator() Iterator

returns a function that in every call return the next value if key is null, no value was retrieved

func (*LinkedHashMap) Put

func (this *LinkedHashMap) Put(key Hasher, value interface{}) interface{}

func (*LinkedHashMap) Size

func (this *LinkedHashMap) Size() int

func (*LinkedHashMap) String

func (this *LinkedHashMap) String() string

func (*LinkedHashMap) Values

func (this *LinkedHashMap) Values() []interface{}

type LinkedHashMapIterator

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

func (*LinkedHashMapIterator) HasNext

func (this *LinkedHashMapIterator) HasNext() bool

func (*LinkedHashMapIterator) Next

func (this *LinkedHashMapIterator) Next() *KeyValue

func (*LinkedHashMapIterator) Peek

func (this *LinkedHashMapIterator) Peek() *KeyValue

func (*LinkedHashMapIterator) Remove

func (this *LinkedHashMapIterator) Remove()

type LinkedHashSet

type LinkedHashSet struct {
	HashSet
}

func NewLinkedHashSet

func NewLinkedHashSet() *LinkedHashSet

func (*LinkedHashSet) Clear

func (this *LinkedHashSet) Clear()

func (*LinkedHashSet) HashCode

func (this *LinkedHashSet) HashCode() int

type Map

type Map interface {
	Base

	Put(key Hasher, Value interface{}) interface{}
	Get(key Hasher) (interface{}, bool)
	Delete(key Hasher) interface{}

	Size() int
	Clear()

	Iterator() Iterator
	Elements() []*KeyValue
	Values() []interface{}
}

Jump to

Keyboard shortcuts

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