Documentation
¶
Overview ¶
list provides the List data structure.
A List is a doubly-linked list.
Index ¶
- type Iterator
- type List
- func (l *List[T]) Collect(items ...T)
- func (l *List[T]) Del(index int) (*T, error)
- func (l *List[T]) Dequeue() (*T, error)
- func (l *List[T]) Enqueue(elem T)
- func (l *List[T]) FromIterator(iter iterator.Iterator[T]) error
- func (l *List[T]) Get(index int) (*T, error)
- func (l *List[T]) Ins(index int, elem T) error
- func (l *List[T]) IntoIterator() iterator.Iterator[T]
- func (l *List[T]) Peek() (*T, error)
- func (l *List[T]) PeekBack() (*T, error)
- func (l *List[T]) PeekFront() (*T, error)
- func (l *List[T]) Pop() (*T, error)
- func (l *List[T]) PopBack() (*T, error)
- func (l *List[T]) PopFront() (*T, error)
- func (l *List[T]) Push(elem T)
- func (l *List[T]) PushBack(item T)
- func (l *List[T]) PushFront(item T)
- func (l *List[T]) Set(index int, item T) error
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 provides an iterator over the List type.
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List is the doubly-linked list data structure.
func (*List[T]) Collect ¶
func (l *List[T]) Collect(items ...T)
Collect appends a variable number of items to the list.
func (*List[T]) Del ¶
Del removes and returns an element from the list at the specified index. Returns errors.IndexOutOfBounds if index < 0 or index > len(l).
func (*List[T]) Enqueue ¶
func (l *List[T]) Enqueue(elem T)
Enqueue appends an item to the end of the list.
func (*List[T]) FromIterator ¶
FromIterator collects the items from the iterator into the list.
func (*List[T]) Get ¶
Get returns a pointer to an item in the List located at index. Returns nil, errors.Empty if the List is empty. Returns nil, errors.IndexOutOfBounds if index < 0 or index > len(l).
func (*List[T]) Ins ¶
Ins inserts an element into the list at the specified index. Returns errors.IndexOutOfBounds if index < 0 or index > len(l).
func (*List[T]) IntoIterator ¶
IntoIterator returns an iterator over the items in the list.
func (*List[T]) PeekBack ¶
PeekBack returns a pointer to the back of the List. Returns nil, errors.Empty if the List is empty.
func (*List[T]) PeekFront ¶
PeekFront returns a pointer to the front of the List. Returns nil, errors.Empty if the List is empty.
func (*List[T]) PopBack ¶
PopBack removes and returns an item from the back of the List. Returns nil, errors.Empty if the List is empty.
func (*List[T]) PopFront ¶
PopFront removes and returns an item from the front of the List. Returns nil, errors.Empty if the List is empty.
func (*List[T]) PushBack ¶
func (l *List[T]) PushBack(item T)
PushBack pushes an item onto the back of the doubly-linked list.