Documentation
¶
Index ¶
- type Deque
- type Heap
- type Set
- func (s Set[T]) Add(items ...T)
- func (s Set[T]) AddSet(other Set[T])
- func (s Set[T]) All() iter.Seq[T]
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Del(ts ...T)
- func (s Set[T]) Equal(other Set[T]) bool
- func (s Set[T]) Has(t T) bool
- func (s Set[T]) IsSubsetOf(other Set[T]) bool
- func (s Set[T]) Size() int
- func (s Set[T]) Slice() []T
- func (s Set[T]) Subtract(other Set[T])
- type Stack
- type SyncMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deque ¶
type Deque[T any] struct { // contains filtered or unexported fields }
Deque is a generic double-ended queue. A zero value is not ready to use, acquire one using NewDeque.
func (*Deque[T]) Pop ¶
func (d *Deque[T]) Pop() T
Pop removes and returns the item at the front of the Deque. Panics if called on an empty Deque.
func (*Deque[T]) PopBack ¶
func (d *Deque[T]) PopBack() T
PopBack removes and returns the item at the back of the Deque. Panics if called on an empty Deque.
func (*Deque[T]) Push ¶
func (d *Deque[T]) Push(v T)
Push appends v to the back of the Deque, such that v would be returned by an immediate call to PopBack()
type Heap ¶
type Heap[T any] struct { // contains filtered or unexported fields }
Heap implements a binary min-heap. It can be used as a priority queue. Each item is given an integer priority upon insertion. Since Heap is a min-heap, lower integers have higher priority.
func BuildHeap ¶
BuildHeap returns a heap with the given items. items[i] is given priority prios[i].
func (*Heap[T]) Extract ¶
func (h *Heap[T]) Extract() T
Extract removes and returns the highest priority item.
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a set data structure that keeps track of items. A zero-value Set is not ready to use, create one using NewSet.
func NewSet ¶
func NewSet[T comparable](capacity int) Set[T]
NewSet returns a Set with the specified capacity.
func SetFromIter ¶
func SetFromIter[T comparable](seq iter.Seq[T]) Set[T]
SetFromIter returns a Set that contains the items in the iterator.
func SetFromSlice ¶
func SetFromSlice[T comparable](items []T) Set[T]
SetFromSlice returns a Set with all items in s present in the set. A utility to simplify set creation + initialization.
func (Set[T]) Del ¶
func (s Set[T]) Del(ts ...T)
Del removes all the provided elements from the set. Has no effect when called with an item that does not exist in the set.
func (Set[T]) IsSubsetOf ¶
IsSubsetOf returns whether s is a subset of other.
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
Stack is a stack. A zero value is ready to use.
func NewStack ¶
NewStack returns a Stack with the specified capacity. This capacity may prevent memory allocations when working with the stack.
type SyncMap ¶
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }
SyncMap is a type-safe thread-safe map.
func NewSyncMap ¶
func NewSyncMap[K comparable, V any](capacity int) *SyncMap[K, V]
NewSyncMap returns a new SyncMap.
func (*SyncMap[K, V]) All ¶
All returns an iterator over the SyncMap. This method is intentionally not thread-safe. Meant to be used once concurrent ops are no longer being done.
func (*SyncMap[K, V]) Del ¶
func (s *SyncMap[K, V]) Del(k K)
Del removes k from the map. Does nothing if the key does not exist.