Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNodeNotFound = errors.New("node not found")
Functions ¶
This section is empty.
Types ¶
type LinkedList ¶
type LinkedList[E any] struct { // contains filtered or unexported fields }
LinkedList is a data structure allowing for quick insertion and deletion. Access O(n) Search O(n) * Insert O(1) for known node location -or- O(n) search for node location * Delete O(1) for known node location -or- O(n) search for node location
func (*LinkedList[E]) Delete ¶
func (l *LinkedList[E]) Delete(n Node[E]) error
func (*LinkedList[E]) Head ¶
func (l *LinkedList[E]) Head() Node[E]
func (*LinkedList[E]) InsertAfter ¶
func (l *LinkedList[E]) InsertAfter(parent *node[E], new *node[E])
func (*LinkedList[E]) InsertBefore ¶
func (l *LinkedList[E]) InsertBefore(parent *node[E], new *node[E])
func (*LinkedList[E]) Len ¶
func (l *LinkedList[E]) Len() int
func (*LinkedList[E]) Tail ¶
func (l *LinkedList[E]) Tail() Node[E]
type LinkedLister ¶
type LinkedLister[E any] interface { Head() node[E] Tail() node[E] InsertBefore(parent *node[E], new *node[E]) InsertAfter(parent *node[E], new *node[E]) Delete(n *node[E]) error Len() int }
LinkedLister is a data structure allowing for quick insertion and deletion. Access O(n) Search O(n) * Insert O(1) for known node location -or- O(n) search for node location * Delete O(1) for known node location -or- O(n) search for node location
type Node ¶
type Node[E any] interface { Data() *E Next() Node[E] Prev() Node[E] Connect(first, second Node[E]) // Remove(n Node[E]) InsertBetween(first, second Node[E]) SetData(data *E) SetNext(Node[E]) SetPrev(Node[E]) Clear() }
LinkedList is a data structure allowing for quick insertion and deletion. Access O(n) Search O(n) * Insert O(1) for known node location -or- O(n) search for node location * Delete O(1) for known node location -or- O(n) search for node location