Documentation ¶
Overview ¶
Package frozen provides immutable data structures.
Index ¶
- func Equal(a, b interface{}) bool
- type BitIterator
- type Equatable
- type IntIterator
- type IntLess
- type IntSet
- func (s IntSet) Any() int
- func (s IntSet) Count() int
- func (s IntSet) Elements() []int
- func (s IntSet) EqualSet(t IntSet) bool
- func (s IntSet) Has(val int) bool
- func (s IntSet) Intersection(t IntSet) IntSet
- func (s IntSet) IsEmpty() bool
- func (s IntSet) IsSubsetOf(t IntSet) bool
- func (s IntSet) Map(f func(elem int) int) IntSet
- func (s IntSet) Range() IntIterator
- func (s IntSet) String() string
- func (s IntSet) Union(t IntSet) IntSet
- func (s IntSet) Where(pred func(elem int) bool) IntSet
- func (s IntSet) With(is ...int) IntSet
- func (s IntSet) Without(is ...int) IntSet
- type Iterator
- type Key
- type KeyValue
- type Less
- type Map
- func (m Map) Any() (key, value interface{})
- func (m Map) Count() int
- func (m Map) Equal(i interface{}) bool
- func (m Map) Format(state fmt.State, _ rune)
- func (m Map) Get(key interface{}) (interface{}, bool)
- func (m Map) GetElse(key, deflt interface{}) interface{}
- func (m Map) GetElseFunc(key interface{}, deflt func() interface{}) interface{}
- func (m Map) Has(key interface{}) bool
- func (m Map) Hash(seed uintptr) uintptr
- func (m Map) IsEmpty() bool
- func (m Map) Keys() Set
- func (m Map) Map(f func(key, val interface{}) interface{}) Map
- func (m Map) MarshalJSON() ([]byte, error)
- func (m Map) Merge(n Map, resolve func(key, a, b interface{}) interface{}) Map
- func (m Map) MustGet(key interface{}) interface{}
- func (m Map) Project(keys Set) Map
- func (m Map) Range() *MapIterator
- func (m Map) Reduce(f func(acc, key, val interface{}) interface{}, acc interface{}) interface{}
- func (m Map) String() string
- func (m Map) Update(n Map) Map
- func (m Map) Values() Set
- func (m Map) Where(pred func(key, val interface{}) bool) Map
- func (m Map) With(key, val interface{}) Map
- func (m Map) Without(keys Set) Map
- type MapBuilder
- type MapIterator
- type MaskIterator
- type Set
- func CartesianProduct(relations ...Set) Set
- func Intersection(sets Set) Set
- func Iota(stop int) Set
- func Iota2(start, stop int) Set
- func Iota3(start, stop, step int) Set
- func Join(relations Set) Set
- func NewRelation(header []interface{}, rows ...[]interface{}) Set
- func NewSet(values ...interface{}) Set
- func NewSetFromMask64(mask uint64) Set
- func NewSetFromStrings(values ...string) Set
- func Union(sets ...Set) Set
- func (s Set) Any() interface{}
- func (s Set) AnyN(n int) Set
- func (s Set) CartesianProduct(t Set) Set
- func (s Set) Count() int
- func (s Set) Difference(t Set) Set
- func (s Set) Elements() []interface{}
- func (s Set) Equal(t interface{}) bool
- func (s Set) EqualSet(t Set) bool
- func (s Set) First(less Less) interface{}
- func (s Set) FirstN(n int, less Less) Set
- func (s Set) Format(state fmt.State, _ rune)
- func (s Set) GroupBy(key func(el interface{}) interface{}) Map
- func (s Set) Has(val interface{}) bool
- func (s Set) Hash(seed uintptr) uintptr
- func (s Set) Intersection(t Set) Set
- func (s Set) IsEmpty() bool
- func (s Set) IsSubsetOf(t Set) bool
- func (s Set) Join(t Set) Set
- func (s Set) Map(f func(elem interface{}) interface{}) Set
- func (s Set) MarshalJSON() ([]byte, error)
- func (s Set) Nest(attrAttrs Map) Set
- func (s Set) OrderedElements(less Less) []interface{}
- func (s Set) OrderedFirstN(n int, less Less) []interface{}
- func (s Set) OrderedRange(less Less) Iterator
- func (s Set) Powerset() Set
- func (s Set) Project(attrs Set) Set
- func (s Set) Range() Iterator
- func (s Set) Reduce(reduce func(elems ...interface{}) interface{}) interface{}
- func (s Set) Reduce2(reduce func(a, b interface{}) interface{}) interface{}
- func (s Set) String() string
- func (s Set) SymmetricDifference(t Set) Set
- func (s Set) Union(t Set) Set
- func (s Set) Unnest(attrs Set) Set
- func (s Set) Where(pred func(elem interface{}) bool) Set
- func (s Set) With(values ...interface{}) Set
- func (s Set) Without(values ...interface{}) Set
- type SetBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BitIterator ¶
type BitIterator uintptr
BitIterator represents a set of one-bits and the ability to enumerate them.
func (BitIterator) Count ¶
func (b BitIterator) Count() int
func (BitIterator) Has ¶
func (b BitIterator) Has(i int) bool
func (BitIterator) Index ¶
func (b BitIterator) Index() int
func (BitIterator) Next ¶
func (b BitIterator) Next() BitIterator
func (BitIterator) String ¶
func (b BitIterator) String() string
func (BitIterator) With ¶
func (b BitIterator) With(i int) BitIterator
func (BitIterator) Without ¶
func (b BitIterator) Without(i int) BitIterator
type Equatable ¶
type Equatable interface {
Equal(interface{}) bool
}
Equatable represents a type that can be compared for equality with another value.
type IntIterator ¶
type IntSet ¶
type IntSet struct {
// contains filtered or unexported fields
}
func (IntSet) Intersection ¶
Intersection returns an IntSet whose values exists in s and t.
func (IntSet) IsSubsetOf ¶
IsSubsetOf returns true if s is a subset of t and false otherwise.
type Iterator ¶
type Iterator interface { Next() bool Value() interface{} }
Iterator provides for iterating over a Set.
type KeyValue ¶
type KeyValue struct {
Key, Value interface{}
}
KeyValue represents a key-value pair for insertion into a Map.
func (KeyValue) Equal ¶
Equal returns true iff i is a KeyValue whose key equals this KeyValue's key.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map maps keys to values. The zero value is the empty Map.
func NewMapFromGoMap ¶
func NewMapFromGoMap(m map[interface{}]interface{}) Map
NewMapFromGoMap takes a map[interface{}]interface{} and returns a frozen Map from it.
func NewMapFromKeys ¶
NewMapFromKeys creates a new Map in which values are computed from keys.
func (Map) Any ¶
func (m Map) Any() (key, value interface{})
Any returns an arbitrary entry from the Map.
func (Map) GetElse ¶
func (m Map) GetElse(key, deflt interface{}) interface{}
GetElse returns the value associated with key in m or deflt if the key is not found.
func (Map) GetElseFunc ¶
func (m Map) GetElseFunc(key interface{}, deflt func() interface{}) interface{}
GetElseFunc returns the value associated with key in m or the result of calling deflt if the key is not found.
func (Map) Map ¶
Map returns a Map with keys from this Map, but the values replaced by the result of calling f.
func (Map) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Map) Merge ¶
Merge returns a map from the merging between two maps, should there be a key overlap, the value that corresponds to key will be replaced by the value resulted from the provided resolve function.
func (Map) MustGet ¶
func (m Map) MustGet(key interface{}) interface{}
MustGet returns the value associated with key in m or panics if the key is not found.
func (Map) Reduce ¶
func (m Map) Reduce(f func(acc, key, val interface{}) interface{}, acc interface{}) interface{}
Reduce returns the result of applying f to each key-value pair on the Map. The result of each call is used as the acc argument for the next element.
func (Map) Update ¶
Update returns a Map with key-value pairs from n added or replacing existing keys.
type MapBuilder ¶
type MapBuilder struct {
// contains filtered or unexported fields
}
MapBuilder provides a more efficient way to build Maps incrementally.
func NewMapBuilder ¶
func NewMapBuilder(capacity int) *MapBuilder
func (*MapBuilder) Count ¶
func (b *MapBuilder) Count() int
Count returns the number of entries in the Map under construction.
func (*MapBuilder) Finish ¶
func (b *MapBuilder) Finish() Map
Finish returns a Map containing all entries added since the MapBuilder was initialised or the last call to Finish.
func (*MapBuilder) Get ¶
func (b *MapBuilder) Get(key interface{}) (interface{}, bool)
Get returns the value for key from the Map under construction or false if not found.
func (*MapBuilder) Put ¶
func (b *MapBuilder) Put(key, value interface{})
Put adds or changes an entry into the Map under construction.
func (*MapBuilder) Remove ¶
func (b *MapBuilder) Remove(key interface{})
Remove removes an entry from the Map under construction.
type MapIterator ¶
type MapIterator struct {
// contains filtered or unexported fields
}
MapIterator provides for iterating over a Map.
func (*MapIterator) Entry ¶
func (i *MapIterator) Entry() (key, value interface{})
Entry returns the current key-value pair as two return values.
func (*MapIterator) Key ¶
func (i *MapIterator) Key() interface{}
Key returns the key for the current entry.
func (*MapIterator) Next ¶
func (i *MapIterator) Next() bool
Next moves to the next key-value pair or returns false if there are no more.
func (*MapIterator) Value ¶
func (i *MapIterator) Value() interface{}
Value returns the value for the current entry.
type MaskIterator ¶
type MaskIterator uint16
MaskIterator represents a set of one-bits and the ability to enumerate them.
func (MaskIterator) Count ¶
func (b MaskIterator) Count() int
func (MaskIterator) Has ¶
func (b MaskIterator) Has(i int) bool
func (MaskIterator) Index ¶
func (b MaskIterator) Index() int
func (MaskIterator) Next ¶
func (b MaskIterator) Next() MaskIterator
func (MaskIterator) String ¶
func (b MaskIterator) String() string
func (MaskIterator) With ¶
func (b MaskIterator) With(i int) MaskIterator
func (MaskIterator) Without ¶
func (b MaskIterator) Without(i int) MaskIterator
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set holds a set of values. The zero value is the empty Set.
func CartesianProduct ¶
func Intersection ¶
Intersection returns the n-ary intersection of a Set of Sets.
func Iota3 ¶
Iota3 returns a Set with elements {start, start+step, start+2*step, ...} up to but not including stop. Negative steps are allowed.
func NewRelation ¶
func NewRelation(header []interface{}, rows ...[]interface{}) Set
NewRelation returns a new set of maps, each having the same keys.
func NewSet ¶
func NewSet(values ...interface{}) Set
NewSet creates a new Set with values as elements.
func NewSetFromMask64 ¶
NewSetFromMask64 returns a Set containing all elements 2**i such that bit i of mask is set.
func NewSetFromStrings ¶
NewSetFromStrings creates a new Set with values as elements.
func (Set) CartesianProduct ¶
func (Set) Difference ¶
Difference returns a Set with all elements that are s but not in t.
func (Set) Intersection ¶
Intersection returns a Set with all elements that are in both s and t.
func (Set) IsSubsetOf ¶
IsSubsetOf returns true iff no element in s is not in t.
func (Set) Join ¶
Join returns all {x, y, z} such that s has {x, y} and t has {y, z}. x, y and z represent sets of keys:
x: keys unique to maps in s y: keys common to maps in both z: keys unique to maps in t
It is assumed that all maps in s have the same keys and likewise for t.
func (Set) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Set) Nest ¶
Nest returns a relation with some attributes nested as subrelations.
Example:
input: _c_ _a__ |_1_|_10_| |_1_|_11_| |_2_|_13_| |_3_|_11_| |_4_|_14_| |_3_|_10_| |_4_|_13_| nest(input, ("aa": {"a"})): _c_ ___aa___ | 1 | _a__ | | | |_10_| | |___|_|_11_|_| | 2 | _a__ | |___|_|_13_|_| | 3 | _a__ | | | |_10_| | |___|_|_11_|_| | 4 | _a__ | | | |_13_| | |___|_|_14_|_|
func (Set) OrderedElements ¶
OrderedElements takes elements in a defined order.
func (Set) OrderedFirstN ¶
OrderedFirstN returns a list of elements in a defined order.
func (Set) OrderedRange ¶
OrderedRange returns a SetIterator for the Set that iterates over the elements in a specified order.
func (Set) Reduce ¶
func (s Set) Reduce(reduce func(elems ...interface{}) interface{}) interface{}
Reduce returns the result of applying `reduce` to the elements of `s` or `nil` if `s.IsEmpty()`. The result of each call is used as the acc argument for the next element.
The `reduce` function must have the following properties:
- commutative: `reduce(a, b, c) == reduce(c, a, b)`
- associative: `reduce(reduce(a, b), c) == reduce(a, reduce(b, c))`
By implication, `reduce` must accept its own output as input.
'elems` will never be empty.
func (Set) Reduce2 ¶
func (s Set) Reduce2(reduce func(a, b interface{}) interface{}) interface{}
Reduce2 is a convenience wrapper for `Reduce`, allowing the caller to implement a simpler, albeit less efficient, binary `reduce` function instead of an n-adic one.
func (Set) SymmetricDifference ¶
SymmetricDifference returns a Set with all elements that are s or t, but not both.
func (Set) Unnest ¶
Unnest returns a relation with some subrelations unnested. This is the reverse of Nest.
type SetBuilder ¶
type SetBuilder struct {
// contains filtered or unexported fields
}
SetBuilder provides a more efficient way to build sets incrementally.
func NewSetBuilder ¶
func NewSetBuilder(capacity int) *SetBuilder
func (*SetBuilder) Add ¶
func (b *SetBuilder) Add(v interface{})
Add adds el to the Set under construction.
func (*SetBuilder) Count ¶
func (b *SetBuilder) Count() int
Count returns the count of the Set that will be returned from Finish().
func (*SetBuilder) Finish ¶
func (b *SetBuilder) Finish() Set
Finish returns a Set containing all elements added since the SetBuilder was initialised or the last call to Finish.
func (*SetBuilder) Has ¶
func (b *SetBuilder) Has(el interface{}) bool
func (*SetBuilder) Remove ¶
func (b *SetBuilder) Remove(v interface{})
Remove removes el to the Set under construction.