Documentation
¶
Overview ¶
Package indexedset provides a generic set that assigns a stable index to each unique key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexedSet ¶
type IndexedSet[K comparable] struct { // contains filtered or unexported fields }
IndexedSet is a set that assigns a stable index to each unique key added to it.
func (*IndexedSet[K]) Add ¶
func (s *IndexedSet[K]) Add(k K) int32
Add adds a key and returns its index in the set.
func (*IndexedSet[K]) AddSlice ¶
func (s *IndexedSet[K]) AddSlice(ks []K) []int32
AddSlice adds all the keys from the slice and returns all the corresponding indexes.
func (*IndexedSet[K]) Size ¶
func (s *IndexedSet[K]) Size() int
Size returns the number of entries in the set.
func (*IndexedSet[K]) Subset ¶
func (s *IndexedSet[K]) Subset(indexes []int32) []K
Subset returns all the keys corresponding to the provided indexes.
func (*IndexedSet[K]) UniqueKeys ¶
func (s *IndexedSet[K]) UniqueKeys() []K
UniqueKeys returns all the unique keys in the set, in insertion order. It returns a reference which should not be modifed by the caller (unless the caller is done with the IndexedSet completely)
Click to show internal directories.
Click to hide internal directories.