Documentation
¶
Index ¶
- type List
- func (list *List[T]) All() iter.Seq[*List[T]]
- func (list *List[T]) Backward() iter.Seq[*List[T]]
- func (list *List[T]) InsertAfter(v T) *List[T]
- func (list *List[T]) InsertBefore(v T) *List[T]
- func (list *List[T]) InsertSeqAfter(seq iter.Seq[T]) *List[T]
- func (list *List[T]) InsertSeqBefore(seq iter.Seq[T]) *List[T]
- func (list *List[T]) Next() *List[T]
- func (list *List[T]) Prev() *List[T]
- func (list *List[T]) Remove() *List[T]
- func (list *List[T]) Values() iter.Seq[T]
- func (list *List[T]) ValuesBackward() iter.Seq[T]
- type OrderedMap
- func (m *OrderedMap[K, V]) All() iter.Seq2[K, V]
- func (m *OrderedMap[K, V]) Clear()
- func (m *OrderedMap[K, V]) Delete(key K)
- func (m *OrderedMap[K, V]) Keys() iter.Seq[K]
- func (m *OrderedMap[K, V]) Lookup(key K) (val V, ok bool)
- func (m *OrderedMap[K, V]) Set(key K, val V)
- func (m *OrderedMap[K, V]) Values() iter.Seq[V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
type List[T any] struct { Val T // contains filtered or unexported fields }
List is a doubly-linked circular list. Any element in the list is a reference to the whole list. A zero-value List is not valid, but a nil *List is and is the correct representation of an empty list.
func NewListFromSeq ¶
NewListFromSeq returns a List containing the values yielded by seq.
func (*List[T]) All ¶
All returns an iter.Seq that yields the nodes of the List in next order, starting with list itself, once each.
For most situations, [Values] is more convenient.
func (*List[T]) Backward ¶
Backward returns an iter.Seq that yields the nodes of the List in prev order, starting with list itself, once each.
For most situations, [ValuesBackward] is more convenient.
func (*List[T]) InsertAfter ¶
InsertAfter inserts v as a new node in between list and the node after it. It returns list, possibly modified. Similar to [append], the existing list should always be replaced with the result of this function.
func (*List[T]) InsertBefore ¶
InsertBefore inserts v as a new node in between list and the node before it. It returns list, possibly modified. Similar to [append], the existing list should always be replaced with the result of this function.
func (*List[T]) InsertSeqAfter ¶
InsertSeqAfter inserts the values yielded by seq as new nodes after list. The order of the elements in the List will be the same as they were in seq. The behavior of this function is otherwise the same as that of [InsertBefore].
func (*List[T]) InsertSeqBefore ¶
InsertSeqBefore inserts the values yielded by seq as new nodes before list. The order of the elements in the List will be the same as they were in seq. The behavior of this function is otherwise the same as that of [InsertBefore].
func (*List[T]) Remove ¶
Remove removes list from the List that it represents. It returns the node before list. list is no longer valid after a call to Remove.
func (*List[T]) Values ¶
Values returns an iter.Seq that yields the values of each node in the List in next order, starting with that of list itself, once each.
func (*List[T]) ValuesBackward ¶
ValuesBackward returns an iter.Seq that yields the values of each node in the List in prev order, starting with that of list itself, once each.
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap is similar to Go's built-in map type, but maintains insertion order for iteration. In other words, if element b is inserted after element a is already in the map, b will always be yieled after a during iteration.
Unlike a built-in Go map, a zero-value OrderedMap is empty and ready to use.
func (*OrderedMap[K, V]) All ¶
func (m *OrderedMap[K, V]) All() iter.Seq2[K, V]
All returns an iter.Seq that yields key value pairs in insertion order.
func (*OrderedMap[K, V]) Clear ¶
func (m *OrderedMap[K, V]) Clear()
Clear deletes everything from m, resulting in an empty map.
func (*OrderedMap[K, V]) Delete ¶
func (m *OrderedMap[K, V]) Delete(key K)
Delete removes the value associated with key from the map. If no such value exists, it does nothing.
func (*OrderedMap[K, V]) Keys ¶
func (m *OrderedMap[K, V]) Keys() iter.Seq[K]
Keys returns an iter.Seq that yields keys in insertion order.
func (*OrderedMap[K, V]) Lookup ¶
func (m *OrderedMap[K, V]) Lookup(key K) (val V, ok bool)
Lookup returns the value associated with the key and a boolean indicating if there was one or not.
func (*OrderedMap[K, V]) Set ¶
func (m *OrderedMap[K, V]) Set(key K, val V)
Set sets the provided key to val in m.
func (*OrderedMap[K, V]) Values ¶
func (m *OrderedMap[K, V]) Values() iter.Seq[V]
Values returns an iter.Seq that yields values in insertion order.