Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparer ¶
type Comparer interface { // Returns -1 if a is less than b, returns 1 if a is greater than b, // and returns 0 if a is equal to b. Compare(a, b interface{}) int }
Comparer allows the comparison of two keys for the purpose of sorting.
type Hasher ¶
type Hasher interface { // Computes a 32-bit hash for key. Hash(key interface{}) uint32 // Returns true if a and b are equal. Equal(a, b interface{}) bool }
Hasher hashes keys and checks them for equality.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a dense, ordered, indexed collections. They are analogous to slices in Go. They can be updated by appending to the end of the list, prepending values to the beginning of the list, or updating existing indexes in the list.
func (*List) Get ¶
Get returns the value at the given index. Similar to slices, this method will panic if index is below zero or is greater than or equal to the list size.
func (*List) Iterator ¶
func (l *List) Iterator() *ListIterator
Iterator returns a new iterator for this list positioned at the first index.
func (*List) Set ¶
Set returns a new list with value set at index. Similar to slices, this method will panic if index is below zero or if the index is greater than or equal to the list size.
func (*List) Slice ¶
Slice returns a new list of elements between start index and end index. Similar to slices, this method will panic if start or end are below zero or greater than the list size. A panic will also occur if start is greater than end.
Unlike Go slices, references to inaccessible elements will be automatically removed so they can be garbage collected.
type ListIterator ¶
type ListIterator struct {
// contains filtered or unexported fields
}
ListIterator represents an ordered iterator over a list.
func (*ListIterator) Done ¶
func (itr *ListIterator) Done() bool
Done returns true if no more elements remain in the iterator.
func (*ListIterator) First ¶
func (itr *ListIterator) First()
First positions the iterator on the first index. If source list is empty then no change is made.
func (*ListIterator) Last ¶
func (itr *ListIterator) Last()
Last positions the iterator on the last index. If source list is empty then no change is made.
func (*ListIterator) Next ¶
func (itr *ListIterator) Next() (index int, value interface{})
Next returns the current index and its value & moves the iterator forward. Returns an index of -1 if the there are no more elements to return.
func (*ListIterator) Prev ¶
func (itr *ListIterator) Prev() (index int, value interface{})
Prev returns the current index and value and moves the iterator backward. Returns an index of -1 if the there are no more elements to return.
func (*ListIterator) Seek ¶
func (itr *ListIterator) Seek(index int)
Seek moves the iterator position to the given index in the list. Similar to Go slices, this method will panic if index is below zero or if the index is greater than or equal to the list size.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map represents an immutable hash map implementation. The map uses a Hasher to generate hashes and check for equality of key values.
It is implemented as an Hash Array Mapped Trie.
func NewMap ¶
NewMap returns a new instance of Map. If hasher is nil, a default hasher implementation will automatically be chosen based on the first key added. Default hasher implementations only exist for int, string, and byte slice types.
func (*Map) Delete ¶
Delete returns a map with the given key removed. Removing a non-existent key will cause this method to return the same map.
func (*Map) Get ¶
Get returns the value for a given key and a flag indicating whether the key exists. This flag distinguishes a nil value set on a key versus a non-existent key in the map.
func (*Map) Iterator ¶
func (m *Map) Iterator() *MapIterator
Iterator returns a new iterator for the map.
type MapIterator ¶
type MapIterator struct {
// contains filtered or unexported fields
}
MapIterator represents an iterator over a map's key/value pairs. Although map keys are not sorted, the iterator's order is deterministic.
func (*MapIterator) Done ¶
func (itr *MapIterator) Done() bool
Done returns true if no more elements remain in the iterator.
func (*MapIterator) First ¶
func (itr *MapIterator) First()
First resets the iterator to the first key/value pair.
func (*MapIterator) Next ¶
func (itr *MapIterator) Next() (key, value interface{})
Next returns the next key/value pair. Returns a nil key when no elements remain.
type SortedMap ¶
type SortedMap struct {
// contains filtered or unexported fields
}
SortedMap represents a map of key/value pairs sorted by key. The sort order is determined by the Comparer used by the map.
This map is implemented as a B+tree.
func NewSortedMap ¶
NewSortedMap returns a new instance of SortedMap. If comparer is nil then a default comparer is set after the first key is inserted. Default comparers exist for int, string, and byte slice keys.
func (*SortedMap) Delete ¶
Delete returns a copy of the map with the key removed. Returns the original map if key does not exist.
func (*SortedMap) Get ¶
Get returns the value for a given key and a flag indicating if the key is set. The flag can be used to distinguish between a nil-set key versus an unset key.
func (*SortedMap) Iterator ¶
func (m *SortedMap) Iterator() *SortedMapIterator
Iterator returns a new iterator for this map positioned at the first key.
type SortedMapIterator ¶
type SortedMapIterator struct {
// contains filtered or unexported fields
}
SortedMapIterator represents an iterator over a sorted map. Iteration can occur in natural or reverse order based on use of Next() or Prev().
func (*SortedMapIterator) Done ¶
func (itr *SortedMapIterator) Done() bool
Done returns true if no more key/value pairs remain in the iterator.
func (*SortedMapIterator) First ¶
func (itr *SortedMapIterator) First()
First moves the iterator to the first key/value pair.
func (*SortedMapIterator) Last ¶
func (itr *SortedMapIterator) Last()
Last moves the iterator to the last key/value pair.
func (*SortedMapIterator) Next ¶
func (itr *SortedMapIterator) Next() (key, value interface{})
Next returns the current key/value pair and moves the iterator forward. Returns a nil key if the there are no more elements to return.
func (*SortedMapIterator) Prev ¶
func (itr *SortedMapIterator) Prev() (key, value interface{})
Prev returns the current key/value pair and moves the iterator backward. Returns a nil key if the there are no more elements to return.
func (*SortedMapIterator) Seek ¶
func (itr *SortedMapIterator) Seek(key interface{})
Seek moves the iterator position to the given key in the map. If the key does not exist then the next key is used. If no more keys exist then the iteartor is marked as done.