frozen

package module
v2.0.0-...-cfe7cf8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 IntIterator

type IntIterator[T integer] interface {
	Next() bool
	Value() T
}

type IntLess

type IntLess[T integer] func(a, b T) bool

IntLess dictates the order of two elements.

type IntSet

type IntSet[I integer] struct {
	// contains filtered or unexported fields
}

func NewIntSet

func NewIntSet[I integer](is ...I) IntSet[I]

NewIntSet returns an IntSet with the values provided.

func (IntSet[I]) Any

func (s IntSet[I]) Any() I

Any returns a random value from s.

func (IntSet[I]) Count

func (s IntSet[I]) Count() int

Count returns the number of elements in IntSet.

func (IntSet[I]) Elements

func (s IntSet[I]) Elements() []I

Elements returns all the values of IntSet.

func (IntSet[I]) EqualSet

func (s IntSet[I]) EqualSet(t IntSet[I]) bool

EqualSet returns true if both IntSets are equal.

func (IntSet[I]) Format

func (s IntSet[I]) Format(f fmt.State, verb rune)

Format formats IntSet.

func (IntSet[I]) Has

func (s IntSet[I]) Has(val I) bool

Has returns true if value exists in the IntSet and false otherwise.

func (IntSet[I]) Intersection

func (s IntSet[I]) Intersection(t IntSet[I]) IntSet[I]

Intersection returns an IntSet whose values exists in s and t.

func (IntSet[I]) IsEmpty

func (s IntSet[I]) IsEmpty() bool

IsEmpty returns true if there is no values in s and false otherwise.

func (IntSet[I]) IsSubsetOf

func (s IntSet[I]) IsSubsetOf(t IntSet[I]) bool

IsSubsetOf returns true if s is a subset of t and false otherwise.

func (IntSet[I]) Map

func (s IntSet[I]) Map(f func(elem I) I) IntSet[I]

Map returns an IntSet with whose values are mapped from s.

func (IntSet[I]) Range

func (s IntSet[I]) Range() IntIterator[I]

Range returns the iterator for IntSet.

func (IntSet[I]) String

func (s IntSet[I]) String() string

String returns a string representation of IntSet.

func (IntSet[I]) Union

func (s IntSet[I]) Union(t IntSet[I]) IntSet[I]

Union returns an integer set that is a union of s and t.

func (IntSet[I]) Where

func (s IntSet[I]) Where(pred func(elem I) bool) IntSet[I]

Where returns an IntSet whose values fulfill the provided condition.

func (IntSet[I]) With

func (s IntSet[I]) With(is ...I) IntSet[I]

With returns a new IntSet with the values of s and the provided values.

func (IntSet[I]) Without

func (s IntSet[I]) Without(is ...I) IntSet[I]

Without returns an IntSet without the provided values.

type Map

type Map[K any, V any] struct {
	// contains filtered or unexported fields
}

Map maps keys to values. The zero value is the empty Map.

func NewMap

func NewMap[K any, V any](kvs ...kv.KeyValue[K, V]) Map[K, V]

NewMap creates a new Map with kvs as keys and values.

func NewMapFromGoMap

func NewMapFromGoMap[K comparable, V any](m map[K]V) Map[K, V]

NewMapFromGoMap takes a map[K]V and returns a frozen Map from it.

func NewMapFromKeys

func NewMapFromKeys[K any, V any](keys Set[K], f func(key K) V) Map[K, V]

NewMapFromKeys creates a new Map in which values are computed from keys.

func (Map[K, V]) Any

func (m Map[K, V]) Any() (key K, value V)

Any returns an arbitrary entry from the Map.

func (Map[K, V]) Count

func (m Map[K, V]) Count() int

Count returns the number of entries in the Map.

func (Map[K, V]) DebugReport

func (m Map[K, V]) DebugReport(debug.Tag) string

DebugReport is for internal use.

func (Map[K, V]) EqArgs

func (m Map[K, V]) EqArgs() *tree.EqArgs[kv.KeyValue[K, V]]

func (Map[K, V]) Equal

func (m Map[K, V]) Equal(n Map[K, V]) bool

Equal returns true iff i is a Map with all the same key-value pairs as this Map.

func (Map[K, V]) Format

func (m Map[K, V]) Format(f fmt.State, verb rune)

Format writes a string representation of the Map into state.

func (Map[K, V]) Get

func (m Map[K, V]) Get(key K) (V, bool)

Get returns the value associated with key in m and true iff the key is found.

func (Map[K, V]) GetElse

func (m Map[K, V]) GetElse(key K, deflt V) V

GetElse returns the value associated with key in m or deflt if the key is not found.

func (Map[K, V]) GetElseFunc

func (m Map[K, V]) GetElseFunc(key K, deflt func() V) V

GetElseFunc returns the value associated with key in m or the result of calling deflt if the key is not found.

func (Map[K, V]) Has

func (m Map[K, V]) Has(key K) bool

Has returns true iff the key exists in the map.

func (Map[K, V]) Hash

func (m Map[K, V]) Hash(seed uintptr) uintptr

Hash computes a hash val for s.

func (Map[K, V]) IsEmpty

func (m Map[K, V]) IsEmpty() bool

IsEmpty returns true if the Map has no entries.

func (Map[K, V]) Keys

func (m Map[K, V]) Keys() Set[K]

Keys returns a Set with all the keys in the Map.

func (Map[K, V]) Merge

func (m Map[K, V]) Merge(n Map[K, V], resolve func(key K, a, b V) V) Map[K, V]

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[K, V]) MustGet

func (m Map[K, V]) MustGet(key K) V

MustGet returns the value associated with key in m or panics if the key is not found.

func (Map[K, V]) Project

func (m Map[K, V]) Project(keys Set[K]) Map[K, V]

Project returns a Map with only keys included from this Map.

func (Map[K, V]) Range

func (m Map[K, V]) Range() *MapIterator[K, V]

Range returns a MapIterator over the Map.

func (Map[K, V]) String

func (m Map[K, V]) String() string

String returns a string representatio of the Map.

func (Map[K, V]) Update

func (m Map[K, V]) Update(n Map[K, V]) Map[K, V]

Update returns a Map with key-value pairs from n added or replacing existing keys.

func (Map[K, V]) Values

func (m Map[K, V]) Values() Set[V]

Values returns a Set with all the Values in the Map.

func (Map[K, V]) Where

func (m Map[K, V]) Where(pred func(key K, val V) bool) Map[K, V]

Where returns a Map with only key-value pairs satisfying pred.

func (Map[K, V]) With

func (m Map[K, V]) With(key K, val V) Map[K, V]

With returns a new Map with key associated with val and all other keys retained from m.

func (Map[K, V]) Without

func (m Map[K, V]) Without(keys Set[K]) Map[K, V]

Without returns a new Map with all keys retained from m except the elements of keys.

func (Map[K, V]) Without2

func (m Map[K, V]) Without2(keys ...K) Map[K, V]

Without2 shoves keys into a Set and calls m.Without.

type MapBuilder

type MapBuilder[K any, V any] struct {
	// contains filtered or unexported fields
}

MapBuilder[K, V] provides a more efficient way to build Maps incrementally.

func NewMapBuilder

func NewMapBuilder[K any, V any](capacity int) *MapBuilder[K, V]

func (*MapBuilder[K, V]) Count

func (b *MapBuilder[K, V]) Count() int

Count returns the number of entries in the Map under construction.

func (*MapBuilder[K, V]) Finish

func (b *MapBuilder[K, V]) Finish() Map[K, V]

Finish returns a Map containing all entries added since the MapBuilder[K, V] was initialised or the last call to Finish.

func (*MapBuilder[K, V]) Get

func (b *MapBuilder[K, V]) Get(key K) (V, bool)

Get returns the value for key from the Map under construction or false if not found.

func (*MapBuilder[K, V]) Has

func (b *MapBuilder[K, V]) Has(key K) bool

func (*MapBuilder[K, V]) Put

func (b *MapBuilder[K, V]) Put(key K, value V)

Put adds or changes an entry into the Map under construction.

func (*MapBuilder[K, V]) Remove

func (b *MapBuilder[K, V]) Remove(key K)

Remove removes an entry from the Map under construction.

type MapIterator

type MapIterator[K any, V any] struct {
	// contains filtered or unexported fields
}

MapIterator provides for iterating over a Map.

func (*MapIterator[K, V]) Entry

func (i *MapIterator[K, V]) Entry() (key K, value V)

Entry returns the current key-value pair as two return values.

func (*MapIterator[K, V]) Key

func (i *MapIterator[K, V]) Key() K

Key returns the key for the current entry.

func (*MapIterator[K, V]) Next

func (i *MapIterator[K, V]) Next() bool

Next moves to the next key-value pair or returns false if there are no more.

func (*MapIterator[K, V]) Value

func (i *MapIterator[K, V]) Value() V

Value returns the value for the current entry.

type Set

type Set[T any] struct {
	// contains filtered or unexported fields
}

Set holds a set of values of type T. The zero value is the empty Set.

func Iota

func Iota[T ~int](stop T) Set[T]

Iota returns Iota3(0, stop, 1).

func Iota2

func Iota2[T ~int](start, stop T) Set[T]

Iota2 returns Iota3(start, stop, 1).

func Iota3

func Iota3[T ~int](start, stop, step T) Set[T]

Iota3 returns a Set with elements {start, start+step, start+2*step, ...} up to but not including stop. Negative steps are allowed.

func NewSet

func NewSet[T any](values ...T) Set[T]

NewSet creates a new Set with values as elements.

func NewSetFromMask64

func NewSetFromMask64(mask uint64) Set[int]

NewSetFromMask64 returns a Set containing all elements 2**i such that bit i of mask is set.

func Powerset

func Powerset[T any](s Set[T]) Set[Set[T]]

func (Set[T]) Any

func (s Set[T]) Any() T

Any returns an arbitrary element from the Set.

func (Set[T]) AnyN

func (s Set[T]) AnyN(n int) Set[T]

AnyN returns a set of N arbitrary elements from the Set.

func (Set[T]) Count

func (s Set[T]) Count() int

Count returns the number of elements in the Set.

func (Set[T]) Difference

func (s Set[T]) Difference(t Set[T]) Set[T]

Difference returns a Set with all elements that are s but not in t.

func (Set[T]) Elements

func (s Set[T]) Elements() []T

func (Set[T]) Equal

func (s Set[T]) Equal(t Set[T]) bool

Equal returns true iff s and set have all the same elements.

func (Set[T]) First

func (s Set[T]) First(less tree.Less[T]) interface{}

First returns the first element in a defined order.

func (Set[T]) FirstN

func (s Set[T]) FirstN(n int, less tree.Less[T]) Set[T]

FirstN returns a set of the first n elements in a defined order.

func (Set[T]) Format

func (s Set[T]) Format(f fmt.State, verb rune)

Format writes a string representation of the Set into state.

func (Set[T]) Has

func (s Set[T]) Has(val T) bool

Has returns the value associated with key and true iff the key was found.

func (Set[T]) Hash

func (s Set[T]) Hash(seed uintptr) uintptr

Hash computes a hash value for s.

func (Set[T]) Intersection

func (s Set[T]) Intersection(t Set[T]) Set[T]

Intersection returns a Set with all elements that are in both s and t.

func (Set[T]) IsEmpty

func (s Set[T]) IsEmpty() bool

IsEmpty returns true iff the Set has no elements.

func (Set[T]) IsSubsetOf

func (s Set[T]) IsSubsetOf(t Set[T]) bool

IsSubsetOf returns true iff no element in s is not in t.

func (Set[T]) MarshalJSON

func (s Set[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Set[T]) OrderedElements

func (s Set[T]) OrderedElements(less tree.Less[T]) []T

OrderedElements takes elements in a defined order.

func (Set[T]) OrderedFirstN

func (s Set[T]) OrderedFirstN(n int, less tree.Less[T]) []T

OrderedFirstN returns a list of elements in a defined order.

func (Set[T]) OrderedRange

func (s Set[T]) OrderedRange(less tree.Less[T]) iterator.Iterator[T]

OrderedRange returns a SetIterator for the Set that iterates over the elements in a specified order.

func (Set[T]) Range

func (s Set[T]) Range() iterator.Iterator[T]

Range returns an Iterator over the Set.

func (Set[T]) String

func (s Set[T]) String() string

String returns a string representation of the Set.

func (Set[T]) SymmetricDifference

func (s Set[T]) SymmetricDifference(t Set[T]) Set[T]

SymmetricDifference returns a Set with all elements that are s or t, but not both.

func (Set[T]) Union

func (s Set[T]) Union(t Set[T]) Set[T]

Union returns a Set with all elements that are in either s or t.

func (Set[T]) Where

func (s Set[T]) Where(pred func(elem T) bool) Set[T]

Where returns a Set with all elements that are in s and satisfy pred.

func (Set[T]) With

func (s Set[T]) With(values ...T) Set[T]

With returns a new Set retaining all the elements of the Set as well as values.

func (Set[T]) Without

func (s Set[T]) Without(values ...T) Set[T]

Without returns a new Set with all values retained from Set except values.

type SetBuilder

type SetBuilder[T any] struct {
	// contains filtered or unexported fields
}

SetBuilder[T] provides a more efficient way to build sets incrementally.

func NewSetBuilder

func NewSetBuilder[T any](capacity int) *SetBuilder[T]

func (*SetBuilder[T]) Add

func (b *SetBuilder[T]) Add(v T)

Add adds el to the Set under construction.

func (*SetBuilder[T]) Count

func (b *SetBuilder[T]) Count() int

Count returns the count of the Set that will be returned from Finish().

func (*SetBuilder[T]) Finish

func (b *SetBuilder[T]) Finish() Set[T]

Finish returns a Set containing all elements added since the SetBuilder[T] was initialised or the last call to Finish.

func (SetBuilder[T]) Format

func (b SetBuilder[T]) Format(f fmt.State, verb rune)

func (*SetBuilder[T]) Has

func (b *SetBuilder[T]) Has(v T) bool

func (*SetBuilder[T]) Remove

func (b *SetBuilder[T]) Remove(v T)

Remove removes el to the Set under construction.

func (SetBuilder[T]) String

func (b SetBuilder[T]) String() string

Directories

Path Synopsis
internal
pkg
kv

Jump to

Keyboard shortcuts

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