Involved Source Fileslist.go
Fully persistent data structures. A persistent data structure is a data
structure that always preserves the previous version of itself when
it is modified. Such data structures are effectively immutable,
as their operations do not update the structure in-place, but instead
always yield a new structure.
Persistent
data structures typically share structure among themselves. This allows
operations to avoid copying the entire data structure.
Package-Level Type Names (total 5, in which 3 are exported)
List is a persistent list of possibly heterogenous values.
Cons returns a new list with val as the head
ForEach executes a callback for each value in the list.
Head returns the first element of the list;
panics if the list is empty
IsNil returns true if the list is empty
Reverse returns a list whose elements are in the opposite order as
the original list.
Size returns the list's length. This takes O(1) time.
Tail returns a list with all elements except the head;
panics if the list is empty
*list
func NewList() List
func List.Cons(val Any) List
func List.Reverse() List
func List.Tail() List
func github.com/lann/builder.listToSlice(list List, arrayType reflect.Type) reflect.Value
A Map associates unique keys (type string) with values (type Any).
Delete returns a new map with the association for key, if any, removed.
This operation is O(log N) in the number of keys.
ForEach executes a callback on each key value pair in the map.
IsNil returns true if the Map is empty
Keys returns a slice with all keys in this map.
This operation is O(N) in the number of keys.
Lookup returns the value associated with a key, if any. If the key
exists, the second return value is true; otherwise, false.
This operation is O(log N) in the number of keys.
Set returns a new map in which key and value are associated.
If the key didn't exist before, it's created; otherwise, the
associated value is changed.
This operation is O(log N) in the number of keys.
Size returns the number of key value pairs in the map.
This takes O(1) time.
( T) String() string
*tree
T : expvar.Var
T : fmt.Stringer
T : context.stringer
T : runtime.stringer
func NewMap() Map
func Map.Delete(key string) Map
func Map.Set(key string, value Any) Map
func github.com/lann/builder.getBuilderMap(builder interface{}) Map
Immutable (i.e. persistent) list
// the number of nodes after, and including, this one
tail*listvalueAny(*T) Cons(val Any) List
ForEach executes a callback for each value in the list
(*T) Head() Any(*T) IsNil() bool
Reverse returns a list with elements in opposite order as this list
(*T) Size() int(*T) Tail() List
*T : List
var nilList *list
children[8]*treecountint
// hash of the key (used for tree balancing)
keystringvalueAny(*T) Delete(key string) Map(*T) ForEach(f func(key string, val Any))(*T) IsNil() bool(*T) Keys() []string(*T) Lookup(key string) (Any, bool)
Set returns a new map similar to this one but with key and value
associated. If the key didn't exist, it's created; otherwise, the
associated value is changed.
(*T) Size() int
make it easier to display maps for debugging
clone returns an exact duplicate of a tree node
delete the leftmost node in a tree returning the node that
was deleted and the tree left over after its deletion
isLeaf returns true if this is a leaf node
returns the number of child subtrees we have
*T : Map
*T : expvar.Var
*T : fmt.Stringer
*T : context.stringer
*T : runtime.stringer
func deleteLowLevel(self *tree, partialHash, hash uint64) (*tree, bool)
func setLowLevel(self *tree, partialHash, hash uint64, key string, value Any) *tree
func deleteLowLevel(self *tree, partialHash, hash uint64) (*tree, bool)
func lookupLowLevel(self *tree, partialHash, hash uint64) (Any, bool)
func recalculateCount(m *tree)
func setLowLevel(self *tree, partialHash, hash uint64, key string, value Any) *tree
var nilMap *tree
Package-Level Functions (total 8, in which 2 are exported)
NewList returns a new, empty list. The result is a singly linked
list implementation. All lists share an empty tail, so allocating
empty lists is efficient in time and memory.
NewMap allocates a new, persistent map from strings to values of
any type.
This is currently implemented as a path-copying binary tree.
Recursively set nilMap's subtrees to point at itself.
This eliminates all nil pointers in the map structure.
All map nodes are created by cloning this structure so
they avoid the problem too.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.