Documentation
¶
Overview ¶
Package linked contains an implementation of a doubly-linked circular list.
Index ¶
- func Index[T comparable](l *Linked[T], v T) int
- type Element
- type Iterator
- type Linked
- func (l *Linked[T]) At(ind int) (*Element[T], error)
- func (l *Linked[T]) Back() *Element[T]
- func (l *Linked[T]) Empty() bool
- func (l *Linked[T]) Front() *Element[T]
- func (l *Linked[T]) InsertAfter(v T, p *Element[T]) *Element[T]
- func (l *Linked[T]) InsertBack(v T) *Element[T]
- func (l *Linked[T]) InsertBefore(v T, p *Element[T]) *Element[T]
- func (l *Linked[T]) InsertFront(v T) *Element[T]
- func (l *Linked[T]) Iter() Iterator[T]
- func (l *Linked[T]) Len() int
- func (l *Linked[T]) Remove(e *Element[T])
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Index ¶
func Index[T comparable](l *Linked[T], v T) int
Index returns the index of the first element with value v, or -1 if not present.
Types ¶
type Element ¶
type Element[T any] struct { Value T // contains filtered or unexported fields }
Element represents an element of the list.
func Find ¶
func Find[T comparable](l *Linked[T], v T) (*Element[T], bool)
Find returns the first element with the value v, or nil if not present. The second parameter is true if the element is found; otherwise, it is false.
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator is an iterator for a linked list.
type Linked ¶
type Linked[T any] struct { // contains filtered or unexported fields }
Linked represents a doubly-linked circular list.
func (*Linked[T]) InsertAfter ¶
InsertAfter inserts a new element with value v immediately after p and returns e. If p is not an element of the list l, nil is returned.
func (*Linked[T]) InsertBack ¶
InsertBack inserts a new element e with value v at the back of the list and returns e.
func (*Linked[T]) InsertBefore ¶
InsertBefore inserts a new element with value v immediately before p and returns e. If p is not an element of the list l, nil is returned.
func (*Linked[T]) InsertFront ¶
InsertFront inserts a new element e with value v at the front of the list and returns e.