Documentation
¶
Index ¶
- Variables
- type Element
- type Iterator
- type List
- func (l *List[T]) Back() *Element[T]
- func (l *List[T]) Clean()
- func (l *List[T]) Front() *Element[T]
- func (l *List[T]) InsertAfter(v T, mark *Element[T]) *Element[T]
- func (l *List[T]) InsertBefore(v T, mark *Element[T]) *Element[T]
- func (l *List[T]) Iterator() Iterator[T]
- func (l *List[T]) Len() int
- func (l *List[T]) MoveAfter(e, mark *Element[T])
- func (l *List[T]) MoveBefore(e, mark *Element[T])
- func (l *List[T]) MoveToBack(e *Element[T])
- func (l *List[T]) MoveToFront(e *Element[T])
- func (l *List[T]) PushBack(v T) *Element[T]
- func (l *List[T]) PushBackList(other *List[T])
- func (l *List[T]) PushFront(v T) *Element[T]
- func (l *List[T]) PushFrontList(other *List[T])
- func (l *List[T]) Remove(e *Element[T]) (v T, err error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrorListElementIsNil = errors.New("list element is nil") ErrorListElementIsNotInTheList = errors.New("list element is not in the list") )
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[T any] struct { // The Value stored with this element. Value T // contains filtered or unexported fields }
Element is an element of a linked list.
type Iterator ¶ added in v0.3.3
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator with ability to validate himself when current element is removed from list.
func NewIterator ¶ added in v0.3.3
Creates iterator. Iterator is not valid until Next() call.
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List represents a doubly linked list.
A doubly linked list (DLL) is a special type of linked list in which each node contains a pointer to the previous node as well as the next node of the linked list.
func NewListPooled ¶
NewListPooled creates new List instance. Pooled tree uses given pool for nodes creating/releasing.
func (*List[T]) Clean ¶
func (l *List[T]) Clean()
Clean cleans list l by removing all existing elements.
func (*List[T]) InsertAfter ¶
InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*List[T]) InsertBefore ¶
InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*List[T]) MoveAfter ¶
MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[T]) MoveBefore ¶
MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[T]) MoveToBack ¶
MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List[T]) MoveToFront ¶
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List[T]) PushBack ¶
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*List[T]) PushBackList ¶
PushBackList inserts a copy of another list at the back of list l. The lists l and other may be the same. They must not be nil.
func (*List[T]) PushFront ¶
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*List[T]) PushFrontList ¶
PushFrontList inserts a copy of another list at the front of list l. The lists l and other may be the same. They must not be nil.