Documentation ¶
Index ¶
- type Iterator
- func (it *Iterator[T]) Get() T
- func (it *Iterator[T]) GetRef() *T
- func (it *Iterator[T]) Index() int
- func (it *Iterator[T]) InsertAfter(value T)
- func (it *Iterator[T]) InsertBefore(value T)
- func (it *Iterator[T]) Move()
- func (it *Iterator[T]) Node() *Node[T]
- func (it *Iterator[T]) Remove()
- func (it *Iterator[T]) Set(value T)
- func (it *Iterator[T]) Valid() bool
- type List
- func (list *List[T]) Append(value T)
- func (list *List[T]) Clear()
- func (list *List[T]) Clone() cols.Collection[T]
- func (list *List[T]) CollectionIterator() cols.Iterator[T]
- func (list *List[T]) FindIndex(predicate predication.Predicate[T]) (int, bool)
- func (list *List[T]) FindNode(predicate predication.Predicate[T]) (*Node[T], bool)
- func (list *List[T]) FindRef(predicate predication.Predicate[T]) (*T, bool)
- func (list *List[T]) Get(index int) T
- func (list *List[T]) GetNode(index int) *Node[T]
- func (list *List[T]) GetRef(index int) *T
- func (list *List[T]) Head() *Node[T]
- func (list *List[T]) Insert(index int, value T)
- func (list *List[T]) Iterator() iter.Iterator[T]
- func (list *List[T]) Join(other cols.Collection[T])
- func (list *List[T]) Prepend(value T)
- func (list *List[T]) RefsStream(yield func(*T) bool)
- func (list *List[T]) Remove(index int)
- func (list *List[T]) RemoveNode(node *Node[T])
- func (list *List[T]) Reverse()
- func (list *List[T]) Set(index int, value T)
- func (list *List[T]) Size() int
- func (list *List[T]) Sort(comparator comparison.Comparator[T])
- func (list *List[T]) Stream(yield func(T) bool)
- func (list *List[T]) Tail() *Node[T]
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator is an iterator over a List.
func (*Iterator[T]) GetRef ¶
func (it *Iterator[T]) GetRef() *T
GetRef returns a reference to the current element.
func (*Iterator[T]) InsertAfter ¶
func (it *Iterator[T]) InsertAfter(value T)
InsertAfter inserts the specified element after the current element. Iterator keeps pointing to the current element.
func (*Iterator[T]) InsertBefore ¶
func (it *Iterator[T]) InsertBefore(value T)
InsertBefore inserts the specified element before the current element. Iterator then points to the inserted element.
func (*Iterator[T]) Move ¶
func (it *Iterator[T]) Move()
Move moves the iterator to the next element.
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List is a doubly linked list implementation. The zero value is ready to use. Do not copy a non-zero List.
func NewFromIterable ¶ added in v1.6.1
NewFromIterable creates a list from the specified iter.Iterable.
func (*List[T]) Append ¶
func (list *List[T]) Append(value T)
Append inserts the specified element at the end of the List.
func (*List[T]) Clone ¶
func (list *List[T]) Clone() cols.Collection[T]
Clone returns a shallow copy of the List.
func (*List[T]) CollectionIterator ¶
CollectionIterator returns an iterator over the elements in the List.
func (*List[T]) FindIndex ¶
func (list *List[T]) FindIndex(predicate predication.Predicate[T]) (int, bool)
FindIndex returns the index of the first element that matches the specified predicate.
func (*List[T]) FindNode ¶
func (list *List[T]) FindNode(predicate predication.Predicate[T]) (*Node[T], bool)
FindNode returns the first node that matches the specified predicate.
func (*List[T]) FindRef ¶
func (list *List[T]) FindRef(predicate predication.Predicate[T]) (*T, bool)
FindRef returns a reference to the first element that matches the specified predicate.
func (*List[T]) Get ¶
Get returns the element at the specified index. Negative indices are interpreted as relative to the end of the List. Panics if the index is out of bounds.
func (*List[T]) GetNode ¶
GetNode returns the node at the specified index. Negative indices are interpreted as relative to the end of the List. Panics if the index is out of bounds.
func (*List[T]) GetRef ¶
GetRef returns a reference to the element at the specified index. Negative indices are interpreted as relative to the end of the List. Panics if the index is out of bounds.
func (*List[T]) Insert ¶
Insert inserts the specified element at the specified index. Negative indices are interpreted as relative to the end of the List. Panics if the index is out of bounds.
func (*List[T]) Join ¶
func (list *List[T]) Join(other cols.Collection[T])
Join appends all elements from the other collection to the List. The other collection is cleared.
func (*List[T]) Prepend ¶
func (list *List[T]) Prepend(value T)
Prepend inserts the specified element at the beginning of the List.
func (*List[T]) RefsStream ¶
RefsStream streams references to the elements in the List.
func (*List[T]) Remove ¶
Remove removes the element at the specified index. Negative indices are interpreted as relative to the end of the List. Panics if the index is out of bounds.
func (*List[T]) RemoveNode ¶
RemoveNode removes the specified node from the List. Panics if the node is not part of the List.
func (*List[T]) Reverse ¶
func (list *List[T]) Reverse()
Reverse reverses the order of the elements in the List.
func (*List[T]) Set ¶
Set sets the element at the specified index. Negative indices are interpreted as relative to the end of the List. Panics if the index is out of bounds.
func (*List[T]) Sort ¶
func (list *List[T]) Sort(comparator comparison.Comparator[T])
Sort sorts the elements in the List by the specified comparator. The sorting algorithm is a stable variant of merge sort.
type Node ¶
type Node[T any] struct { Value T // The value stored in the node. // contains filtered or unexported fields }
Node is an element of a linked list. It should not be created directly.
func (*Node[T]) InsertAfter ¶
func (node *Node[T]) InsertAfter(value T)
InsertAfter inserts the specified element immediately after this node.
func (*Node[T]) InsertBefore ¶
func (node *Node[T]) InsertBefore(value T)
InsertBefore inserts the specified element immediately before this node.