Documentation
¶
Overview ¶
Package hashset implements a set backed by a hash table.
Structure is not thread safe.
References: http://en.wikipedia.org/wiki/Set_%28abstract_data_type%29
Index ¶
- type OrderedIterator
- func (it *OrderedIterator[T]) DistanceTo(other ds.OrderedIterator) int
- func (it *OrderedIterator[T]) Get() (value T, found bool)
- func (it *OrderedIterator[T]) GetAt(i int) (value T, found bool)
- func (it *OrderedIterator[T]) Index() (index int, found bool)
- func (it *OrderedIterator[T]) IsAfter(other ds.OrderedIterator) bool
- func (it *OrderedIterator[T]) IsBefore(other ds.OrderedIterator) bool
- func (it *OrderedIterator[T]) IsBegin() bool
- func (it *OrderedIterator[T]) IsEnd() bool
- func (it *OrderedIterator[T]) IsEqual(other ds.ComparableIterator) bool
- func (it *OrderedIterator[T]) IsFirst() bool
- func (it *OrderedIterator[T]) IsLast() bool
- func (it *OrderedIterator[T]) IsValid() bool
- func (it *OrderedIterator[T]) MoveBy(n int) bool
- func (it *OrderedIterator[T]) MoveTo(i int) bool
- func (it *OrderedIterator[T]) Next() bool
- func (it *OrderedIterator[T]) NextN(i int) bool
- func (it *OrderedIterator[T]) Previous() bool
- func (it *OrderedIterator[T]) PreviousN(n int) bool
- func (it *OrderedIterator[T]) Set(value T) bool
- func (it *OrderedIterator[T]) SetAt(i int, value T) bool
- func (it *OrderedIterator[T]) Size() int
- type Set
- func (set *Set[T]) Add(items ...T)
- func (set *Set[T]) Clear()
- func (set *Set[T]) Contains(items ...T) bool
- func (set *Set[T]) FromJSON(data []byte) error
- func (set *Set[T]) GetValues() []T
- func (set *Set[T]) IsEmpty() bool
- func (set *Set[T]) MakeDifferenceWith(other sets.Set[T]) sets.Set[T]
- func (set *Set[T]) MakeIntersectionWith(other sets.Set[T]) sets.Set[T]
- func (set *Set[T]) MakeUnionWith(other sets.Set[T]) sets.Set[T]
- func (set *Set[T]) MarshalJSON() ([]byte, error)
- func (s *Set[T]) NewOrderedIterator(position int, size int, comparator utils.Comparator[T]) *OrderedIterator[T]
- func (s *Set[T]) OrderedBegin(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
- func (s *Set[T]) OrderedEnd(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
- func (s *Set[T]) OrderedFirst(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
- func (s *Set[T]) OrderedLast(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
- func (set *Set[T]) Remove(_ utils.Comparator[T], items ...T)
- func (set *Set[T]) Size() int
- func (set *Set[T]) ToJSON() ([]byte, error)
- func (set *Set[T]) ToString() string
- func (set *Set[T]) UnmarshalJSON(bytes []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderedIterator ¶ added in v0.9.0
type OrderedIterator[T comparable] struct { // contains filtered or unexported fields }
func (*OrderedIterator[T]) DistanceTo ¶ added in v0.9.0
func (it *OrderedIterator[T]) DistanceTo(other ds.OrderedIterator) int
func (*OrderedIterator[T]) Get ¶ added in v0.9.0
func (it *OrderedIterator[T]) Get() (value T, found bool)
func (*OrderedIterator[T]) GetAt ¶ added in v0.9.0
func (it *OrderedIterator[T]) GetAt(i int) (value T, found bool)
func (*OrderedIterator[T]) Index ¶ added in v0.9.0
func (it *OrderedIterator[T]) Index() (index int, found bool)
func (*OrderedIterator[T]) IsAfter ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsAfter(other ds.OrderedIterator) bool
func (*OrderedIterator[T]) IsBefore ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsBefore(other ds.OrderedIterator) bool
func (*OrderedIterator[T]) IsBegin ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsBegin() bool
func (*OrderedIterator[T]) IsEnd ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsEnd() bool
func (*OrderedIterator[T]) IsEqual ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsEqual(other ds.ComparableIterator) bool
func (*OrderedIterator[T]) IsFirst ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsFirst() bool
func (*OrderedIterator[T]) IsLast ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsLast() bool
func (*OrderedIterator[T]) IsValid ¶ added in v0.9.0
func (it *OrderedIterator[T]) IsValid() bool
func (*OrderedIterator[T]) MoveBy ¶ added in v0.9.0
func (it *OrderedIterator[T]) MoveBy(n int) bool
func (*OrderedIterator[T]) MoveTo ¶ added in v0.9.0
func (it *OrderedIterator[T]) MoveTo(i int) bool
func (*OrderedIterator[T]) Next ¶ added in v0.9.0
func (it *OrderedIterator[T]) Next() bool
func (*OrderedIterator[T]) NextN ¶ added in v0.9.0
func (it *OrderedIterator[T]) NextN(i int) bool
func (*OrderedIterator[T]) Previous ¶ added in v0.9.0
func (it *OrderedIterator[T]) Previous() bool
func (*OrderedIterator[T]) PreviousN ¶ added in v0.9.0
func (it *OrderedIterator[T]) PreviousN(n int) bool
func (*OrderedIterator[T]) Set ¶ added in v0.9.0
func (it *OrderedIterator[T]) Set(value T) bool
func (*OrderedIterator[T]) SetAt ¶ added in v0.9.0
func (it *OrderedIterator[T]) SetAt(i int, value T) bool
func (*OrderedIterator[T]) Size ¶ added in v0.9.0
func (it *OrderedIterator[T]) Size() int
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set holds elements in go's native map
func New ¶
func New[T comparable](values ...T) *Set[T]
New instantiates a new empty set and adds the passed values, if any, to the set
func NewFromIterator ¶ added in v0.9.0
func NewFromIterator[T comparable](beign ds.ReadCompForIndexIterator[int, T]) *Set[T]
NewFromIterator instantiates a new set containing the elements provided by the passed iterator.
func NewFromIterators ¶ added in v0.9.0
func NewFromIterators[T comparable](begin ds.ReadCompForIndexIterator[int, T], end ds.CompIndexIterator[int]) *Set[T]
NewFromIterators instantiates a new set containing the elements provided by first, until it is equal to end. end is a sentinel and not included.
func NewFromSlice ¶ added in v0.9.0
func NewFromSlice[T comparable](slice []T) *Set[T]
NewFromMap instantiates a new set from the provided slice.
func (*Set[T]) Add ¶
func (set *Set[T]) Add(items ...T)
Add adds the items (one or more) to the set.
func (*Set[T]) Contains ¶
Contains check if items (one or more) are present in the set. All items have to be present in the set for the method to return true. Returns true if no arguments are passed at all, i.e. set is always superset of empty set.
func (*Set[T]) GetValues ¶ added in v0.3.0
func (set *Set[T]) GetValues() []T
Values returns all items in the set.
func (*Set[T]) MakeDifferenceWith ¶ added in v0.3.0
Difference returns the difference between two sets. The new set consists of all elements that are in "set" but not in "other". Ref: https://proofwiki.org/wiki/Definition:Set_Difference
func (*Set[T]) MakeIntersectionWith ¶ added in v0.3.0
Intersection returns the intersection between two sets. The new set consists of all elements that are both in "set" and "other". Ref: https://en.wikipedia.org/wiki/Intersection_(set_theory)
func (*Set[T]) MakeUnionWith ¶ added in v0.3.0
Union returns the union of two sets. The new set consists of all elements that are in "set" or "other" (possibly both). Ref: https://en.wikipedia.org/wiki/Union_(set_theory)
func (*Set[T]) MarshalJSON ¶
MarshalJSON @implements json.Marshaler
func (*Set[T]) NewOrderedIterator ¶ added in v0.9.0
func (s *Set[T]) NewOrderedIterator(position int, size int, comparator utils.Comparator[T]) *OrderedIterator[T]
func (*Set[T]) OrderedBegin ¶ added in v0.9.0
func (s *Set[T]) OrderedBegin(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
OrderedBegin returns an initialized, reversed iterator, which points to one element before it's first. Unless Next() is called, the iterator is in an invalid state.
func (*Set[T]) OrderedEnd ¶ added in v0.9.0
func (s *Set[T]) OrderedEnd(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
OrderedEnd returns an initialized,reversed iterator, which points to one element afrer it's last. Unless Previous() is called, the iterator is in an invalid state.
func (*Set[T]) OrderedFirst ¶ added in v0.9.0
func (s *Set[T]) OrderedFirst(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
OrderedFirst returns an initialized, reversed iterator, which points to it's first element.
func (*Set[T]) OrderedLast ¶ added in v0.9.0
func (s *Set[T]) OrderedLast(comparator utils.Comparator[T]) ds.ReadWriteOrdCompBidRandCollIterator[int, T]
OrderedLast returns an initialized, reversed iterator, which points to it's last element.
func (*Set[T]) Remove ¶
func (set *Set[T]) Remove(_ utils.Comparator[T], items ...T)
Remove removes the items (one or more) from the set.
func (*Set[T]) UnmarshalJSON ¶
UnmarshalJSON @implements json.Unmarshaler