containers

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoubleLinkedList added in v0.0.15

type DoubleLinkedList[V any] struct {
	// contains filtered or unexported fields
}

func CollectionAsDoubleLinkedList added in v0.0.15

func CollectionAsDoubleLinkedList[V any](c generics.Collection[int, V, Tuple[int, V]]) *DoubleLinkedList[V]

func NewDoubleLinkedList added in v0.0.15

func NewDoubleLinkedList[V any](values ...V) *DoubleLinkedList[V]

func (*DoubleLinkedList[V]) Append added in v0.0.15

func (s *DoubleLinkedList[V]) Append(v V)

Append adds a new node to the end of the list.

func (*DoubleLinkedList[V]) AppendElem added in v0.0.15

func (s *DoubleLinkedList[V]) AppendElem(elem Tuple[int, V])

func (*DoubleLinkedList[V]) AsCollection added in v0.0.15

func (s *DoubleLinkedList[V]) AsCollection() generics.Collection[int, V, Tuple[int, V]]

func (*DoubleLinkedList[V]) AsIterable added in v0.0.15

func (s *DoubleLinkedList[V]) AsIterable() generics.Iterable[Tuple[int, V]]

func (*DoubleLinkedList[V]) Cap added in v0.0.15

func (s *DoubleLinkedList[V]) Cap() int

func (*DoubleLinkedList[V]) Clear added in v0.0.15

func (s *DoubleLinkedList[V]) Clear()

func (*DoubleLinkedList[V]) Clone added in v0.0.15

func (s *DoubleLinkedList[V]) Clone() generics.Collection[int, V, Tuple[int, V]]

func (*DoubleLinkedList[V]) Delete added in v0.0.15

func (s *DoubleLinkedList[V]) Delete(index int)

Delete removes the node at the given index.

func (*DoubleLinkedList[V]) DeleteFirst added in v0.0.15

func (s *DoubleLinkedList[V]) DeleteFirst()

DeleteFirst removes the first node.

func (*DoubleLinkedList[V]) DeleteLast added in v0.0.15

func (s *DoubleLinkedList[V]) DeleteLast()

DeleteLast removes the last node.

func (*DoubleLinkedList[V]) Factory added in v0.0.15

func (s *DoubleLinkedList[V]) Factory() generics.Collection[int, V, Tuple[int, V]]

func (*DoubleLinkedList[V]) FactoryFrom added in v0.0.15

func (s *DoubleLinkedList[V]) FactoryFrom(values []V) generics.Collection[int, V, Tuple[int, V]]

func (*DoubleLinkedList[V]) First added in v0.0.15

func (s *DoubleLinkedList[V]) First() *DoubleLinkedListNode[V]

func (*DoubleLinkedList[V]) Get added in v0.0.15

func (s *DoubleLinkedList[V]) Get(index int) V

Get returns the value at the given index.

func (*DoubleLinkedList[V]) GetNode added in v0.0.15

func (s *DoubleLinkedList[V]) GetNode(index int) *DoubleLinkedListNode[V]

GetNode returns the node at the given index.

func (*DoubleLinkedList[V]) IsEmpty added in v0.0.15

func (s *DoubleLinkedList[V]) IsEmpty() bool

func (*DoubleLinkedList[V]) Iter added in v0.0.15

func (s *DoubleLinkedList[V]) Iter() *generics.Iterator[Tuple[int, V]]

func (*DoubleLinkedList[V]) IterHandler added in v0.0.15

func (s *DoubleLinkedList[V]) IterHandler(iter *generics.Iterator[Tuple[int, V]])

func (*DoubleLinkedList[V]) Last added in v0.0.15

func (s *DoubleLinkedList[V]) Last() *DoubleLinkedListNode[V]

func (*DoubleLinkedList[V]) Len added in v0.0.15

func (s *DoubleLinkedList[V]) Len() int

func (*DoubleLinkedList[V]) Prepend added in v0.0.15

func (s *DoubleLinkedList[V]) Prepend(v V)

Prepend adds a new node to the beginning of the list.

func (*DoubleLinkedList[V]) Set added in v0.0.15

func (s *DoubleLinkedList[V]) Set(index int, v V)

func (*DoubleLinkedList[V]) SetElem added in v0.0.15

func (s *DoubleLinkedList[V]) SetElem(elem Tuple[int, V])

func (*DoubleLinkedList[V]) Values added in v0.0.15

func (s *DoubleLinkedList[V]) Values() []V

type DoubleLinkedListNode added in v0.0.15

type DoubleLinkedListNode[V any] struct {
	// contains filtered or unexported fields
}

func (*DoubleLinkedListNode[V]) InsertAfter added in v0.0.15

func (n *DoubleLinkedListNode[V]) InsertAfter(list *DoubleLinkedList[V], value V) *DoubleLinkedListNode[V]

InsertAfter inserts a new node after the current node.

func (*DoubleLinkedListNode[V]) InsertBefore added in v0.0.15

func (n *DoubleLinkedListNode[V]) InsertBefore(list *DoubleLinkedList[V], value V) *DoubleLinkedListNode[V]

InsertBefore inserts a new node before the current node.

func (*DoubleLinkedListNode[V]) Next added in v0.0.15

func (n *DoubleLinkedListNode[V]) Next() *DoubleLinkedListNode[V]

Next returns the next node.

func (*DoubleLinkedListNode[V]) Prev added in v0.0.15

func (n *DoubleLinkedListNode[V]) Prev() *DoubleLinkedListNode[V]

Prev returns the previous node.

func (*DoubleLinkedListNode[V]) Set added in v0.0.15

func (n *DoubleLinkedListNode[V]) Set(value V)

Set sets the value of the node.

func (*DoubleLinkedListNode[V]) Value added in v0.0.15

func (n *DoubleLinkedListNode[V]) Value() V

Value returns the value of the node.

type ForwardLinkedList added in v0.0.12

type ForwardLinkedList[V any] struct {
	// contains filtered or unexported fields
}

func CollectionAsForwardLinkedList added in v0.0.12

func CollectionAsForwardLinkedList[V any](c generics.Collection[int, V, Tuple[int, V]]) *ForwardLinkedList[V]

func NewForwardLinkedList added in v0.0.12

func NewForwardLinkedList[V any](values ...V) *ForwardLinkedList[V]

func (*ForwardLinkedList[V]) Append added in v0.0.12

func (s *ForwardLinkedList[V]) Append(v V)

Append adds a new node to the end of the list.

func (*ForwardLinkedList[V]) AppendElem added in v0.0.12

func (s *ForwardLinkedList[V]) AppendElem(elem Tuple[int, V])

func (*ForwardLinkedList[V]) AsCollection added in v0.0.12

func (s *ForwardLinkedList[V]) AsCollection() generics.Collection[int, V, Tuple[int, V]]

func (*ForwardLinkedList[V]) AsIterable added in v0.0.12

func (s *ForwardLinkedList[V]) AsIterable() generics.Iterable[Tuple[int, V]]

func (*ForwardLinkedList[V]) Cap added in v0.0.12

func (s *ForwardLinkedList[V]) Cap() int

func (*ForwardLinkedList[V]) Clear added in v0.0.12

func (s *ForwardLinkedList[V]) Clear()

func (*ForwardLinkedList[V]) Clone added in v0.0.12

func (s *ForwardLinkedList[V]) Clone() generics.Collection[int, V, Tuple[int, V]]

func (*ForwardLinkedList[V]) Delete added in v0.0.12

func (s *ForwardLinkedList[V]) Delete(index int)

func (*ForwardLinkedList[V]) Factory added in v0.0.12

func (s *ForwardLinkedList[V]) Factory() generics.Collection[int, V, Tuple[int, V]]

func (*ForwardLinkedList[V]) FactoryFrom added in v0.0.12

func (s *ForwardLinkedList[V]) FactoryFrom(values []V) generics.Collection[int, V, Tuple[int, V]]

func (*ForwardLinkedList[V]) First added in v0.0.12

func (s *ForwardLinkedList[V]) First() *ForwardLinkedListNode[V]

func (*ForwardLinkedList[V]) Get added in v0.0.12

func (s *ForwardLinkedList[V]) Get(index int) V

Get returns the value at the given index.

func (*ForwardLinkedList[V]) GetNode added in v0.0.12

func (s *ForwardLinkedList[V]) GetNode(index int) *ForwardLinkedListNode[V]

GetNode returns the node at the given index.

func (*ForwardLinkedList[V]) IsEmpty added in v0.0.12

func (s *ForwardLinkedList[V]) IsEmpty() bool

func (*ForwardLinkedList[V]) Iter added in v0.0.12

func (s *ForwardLinkedList[V]) Iter() *generics.Iterator[Tuple[int, V]]

func (*ForwardLinkedList[V]) IterHandler added in v0.0.12

func (s *ForwardLinkedList[V]) IterHandler(iter *generics.Iterator[Tuple[int, V]])

func (*ForwardLinkedList[V]) Last added in v0.0.12

func (s *ForwardLinkedList[V]) Last() *ForwardLinkedListNode[V]

func (*ForwardLinkedList[V]) Len added in v0.0.12

func (s *ForwardLinkedList[V]) Len() int

func (*ForwardLinkedList[V]) Set added in v0.0.12

func (s *ForwardLinkedList[V]) Set(index int, v V)

func (*ForwardLinkedList[V]) SetElem added in v0.0.12

func (s *ForwardLinkedList[V]) SetElem(elem Tuple[int, V])

func (*ForwardLinkedList[V]) Values added in v0.0.12

func (s *ForwardLinkedList[V]) Values() []V

type ForwardLinkedListNode added in v0.0.12

type ForwardLinkedListNode[V any] struct {
	// contains filtered or unexported fields
}

func (*ForwardLinkedListNode[V]) InsertAfter added in v0.0.12

func (n *ForwardLinkedListNode[V]) InsertAfter(list *ForwardLinkedList[V], value V) *ForwardLinkedListNode[V]

InsertAfter inserts a new node after the current node.

func (*ForwardLinkedListNode[V]) Next added in v0.0.12

Next returns the next node.

func (*ForwardLinkedListNode[V]) Set added in v0.0.12

func (n *ForwardLinkedListNode[V]) Set(value V)

Set sets the value of the node.

func (*ForwardLinkedListNode[V]) Value added in v0.0.12

func (n *ForwardLinkedListNode[V]) Value() V

Value returns the value of the node.

type Map added in v0.0.13

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

Map is a generic container for map.

func CollectionAsMap added in v0.0.13

func CollectionAsMap[K comparable, V any](c generics.Collection[K, V, Tuple[K, V]]) *Map[K, V]

func NewMap added in v0.0.13

func NewMap[K comparable, V any](items ...Tuple[K, V]) *Map[K, V]

NewMap creates a new Map.

func (*Map[K, V]) AppendElem added in v0.0.13

func (m *Map[K, V]) AppendElem(elem Tuple[K, V])

AppendElem appends an element to the map.

func (*Map[K, V]) AsCollection added in v0.0.13

func (m *Map[K, V]) AsCollection() generics.Collection[K, V, Tuple[K, V]]

func (*Map[K, V]) AsIterable added in v0.0.13

func (m *Map[K, V]) AsIterable() generics.Iterable[Tuple[K, V]]

func (*Map[K, V]) Cap added in v0.0.13

func (m *Map[K, V]) Cap() int

Cap returns the capacity of the map, which is equal to the length.

func (*Map[K, V]) Clear added in v0.0.13

func (m *Map[K, V]) Clear()

Clear clears the map.

func (*Map[K, V]) Clone added in v0.0.13

func (m *Map[K, V]) Clone() generics.Collection[K, V, Tuple[K, V]]

Clone returns a copy of the map.

func (*Map[K, V]) Delete added in v0.0.13

func (m *Map[K, V]) Delete(key K)

Delete deletes a value from the map.

func (*Map[K, V]) Factory added in v0.0.13

func (m *Map[K, V]) Factory() generics.Collection[K, V, Tuple[K, V]]

Factory returns a new instance of the map.

func (*Map[K, V]) FactoryFrom added in v0.0.13

func (m *Map[K, V]) FactoryFrom(values []V) generics.Collection[K, V, Tuple[K, V]]

func (*Map[K, V]) Get added in v0.0.13

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

Get gets a value from the map. Panics if the key does not exist.

func (*Map[K, V]) GetE added in v0.0.13

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

GetE gets a value from the map.

func (*Map[K, V]) HasKey added in v0.0.13

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

HasKey checks if the map has the key.

func (*Map[K, V]) IsEmpty added in v0.0.13

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

IsEmpty checks if the map is empty.

func (*Map[K, V]) Iter added in v0.0.13

func (m *Map[K, V]) Iter() *generics.Iterator[Tuple[K, V]]

func (*Map[K, V]) IterHandler added in v0.0.13

func (m *Map[K, V]) IterHandler(iter *generics.Iterator[Tuple[K, V]])

func (*Map[K, V]) Keys added in v0.0.13

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

Keys returns all keys in the map.

func (*Map[K, V]) Len added in v0.0.13

func (m *Map[K, V]) Len() int

Len returns the length of the map.

func (*Map[K, V]) Set added in v0.0.13

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

Set sets a value in the map.

func (*Map[K, V]) SetElem added in v0.0.13

func (m *Map[K, V]) SetElem(elem Tuple[K, V])

SetElem sets a value in the map.

func (*Map[K, V]) Values added in v0.0.13

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

Values returns all values in the map.

type Slice added in v0.0.13

type Slice[V any] struct {
	// contains filtered or unexported fields
}

Slice is a generic slice.

It doesn't check out of bounds access.

func CollectionAsSlice added in v0.0.13

func CollectionAsSlice[V any](c generics.Collection[int, V, Tuple[int, V]]) *Slice[V]

func NewSlice added in v0.0.13

func NewSlice[V any](items ...V) *Slice[V]

NewSlice creates a new Slice.

func NewSliceN added in v0.0.13

func NewSliceN[V any](s, n int) *Slice[V]

NewSliceN creates a new Slice with size and capacity of n.

func (*Slice[V]) Append added in v0.0.13

func (s *Slice[V]) Append(item V)

Append appends a value to the slice.

func (*Slice[V]) AppendElem added in v0.0.13

func (s *Slice[V]) AppendElem(elem Tuple[int, V])

AppendElem appends a value to the slice.

func (*Slice[V]) AppendSafeSlice added in v0.0.13

func (s *Slice[V]) AppendSafeSlice(other *Slice[V])

AppendSafeSlice appends a Slice to the slice.

func (*Slice[V]) AppendSlice added in v0.0.13

func (s *Slice[V]) AppendSlice(slice []V)

AppendSlice appends a slice to the slice.

func (*Slice[V]) AsCollection added in v0.0.13

func (s *Slice[V]) AsCollection() generics.Collection[int, V, Tuple[int, V]]

func (*Slice[V]) AsIterable added in v0.0.13

func (s *Slice[V]) AsIterable() generics.Iterable[Tuple[int, V]]

func (*Slice[V]) Cap added in v0.0.13

func (s *Slice[V]) Cap() int

Cap returns the capacity of the slice.

func (*Slice[V]) Clear added in v0.0.13

func (s *Slice[V]) Clear()

Clear clears the slice.

func (*Slice[V]) Clone added in v0.0.13

func (s *Slice[V]) Clone() generics.Collection[int, V, Tuple[int, V]]

Clone returns a clone of the slice. Same as Values.

func (*Slice[V]) Compare added in v0.0.13

func (s *Slice[V]) Compare(i, j Tuple[int, V], comp func(V, V) generics.CompareResult) generics.CompareResult

Compare compares two slice items.

func (*Slice[V]) Delete added in v0.0.13

func (s *Slice[V]) Delete(i int)

Delete deletes a value at given index from the slice.

func (*Slice[V]) Factory added in v0.0.13

func (s *Slice[V]) Factory() generics.Collection[int, V, Tuple[int, V]]

Factory returns a new Slice.

func (*Slice[V]) FactoryFrom added in v0.0.13

func (s *Slice[V]) FactoryFrom(values []V) generics.Collection[int, V, Tuple[int, V]]

func (*Slice[V]) Get added in v0.0.13

func (s *Slice[V]) Get(i int) V

Get gets a value from the slice.

func (*Slice[V]) IsEmpty added in v0.0.13

func (s *Slice[V]) IsEmpty() bool

IsEmpty returns true if the slice is empty.

func (*Slice[V]) Iter added in v0.0.13

func (s *Slice[V]) Iter() *generics.Iterator[Tuple[int, V]]

func (*Slice[V]) IterHandler added in v0.0.13

func (s *Slice[V]) IterHandler(iter *generics.Iterator[Tuple[int, V]])

func (*Slice[V]) Len added in v0.0.13

func (s *Slice[V]) Len() int

Len returns the length of the slice.

func (*Slice[V]) Set added in v0.0.13

func (s *Slice[V]) Set(i int, item V)

Set sets a value in the slice.

func (*Slice[V]) SetElem added in v0.0.13

func (s *Slice[V]) SetElem(item Tuple[int, V])

SetElem sets a value in the slice.

func (*Slice[V]) Slice added in v0.0.13

func (s *Slice[V]) Slice(start, end int) *Slice[V]

Slice returns a new Slice with the elements from start to end-1.

func (*Slice[V]) Values added in v0.0.13

func (s *Slice[V]) Values() []V

Values returns all values in the slice. This function is not thread-safe, use with caution.

type Tuple

type Tuple[K any, V any] struct {
	First  K
	Second V
}

func NewTuple

func NewTuple[K any, V any](first K, second V) Tuple[K, V]

NewTuple creates a new Tuple.

func (Tuple[K, V]) Index

func (t Tuple[K, V]) Index() K

Index is same as Key().

func (Tuple[K, V]) Key

func (t Tuple[K, V]) Key() K

Key returns the first value of the tuple.

func (Tuple[K, V]) String added in v0.2.7

func (t Tuple[K, V]) String() string

String returns a string representation of the tuple.

func (Tuple[K, V]) Value

func (t Tuple[K, V]) Value() V

Value returns the second value of the tuple.

Jump to

Keyboard shortcuts

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