Documentation
¶
Overview ¶
package list wraps doubly-linked list implemented in go programming language standard library, to accept type parameter.
Index ¶
- type Element
- type List
- func (l *List[T]) Back() *Element[T]
- func (l *List[T]) Front() *Element[T]
- func (l *List[T]) Init() *List[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]) 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, hadValue bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[T any] struct { // contains filtered or unexported fields }
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List[T] is `container/list` wrapper that is safe to use with type T.
It holds *`container/list`.List and one extra map (map[*list.Element]*Element[T]) to maintain pointer consistency. The map remembers pointer values it previously returned so a returned pointer is always same pointer for same *`container/list`.Element.
List[T] tries best to be consistent with `container/list`. The zero value of List[T] is a valid empty list (which will be lazily initialized).
func (*List[T]) InsertAfter ¶
func (*List[T]) InsertBefore ¶
func (*List[T]) MoveBefore ¶
func (*List[T]) MoveToBack ¶
func (*List[T]) MoveToFront ¶
func (*List[T]) PushBackList ¶
PushBackList copies values of other and inserts them into back of l.
Both l and other must not be nil.
func (*List[T]) PushFrontList ¶
PushFrontList copies values of other and inserts them into front of l.
Both l and other must not be nil.