Documentation ¶
Index ¶
- Variables
- func DisplayList[T any](head *Node[T])
- func SortLinkedList[T any](ll *LinkedList[T], less func(i, j T) bool)
- func SortLinkedListIterative[T any](ll *LinkedList[T], less func(i, j T) bool)
- type Compariable
- type LinkedList
- func (l *LinkedList[T]) Contains(value T) bool
- func (l *LinkedList[T]) Empty() bool
- func (l *LinkedList[T]) Insert(value T)
- func (l *LinkedList[T]) InsertBefore(node *Node[T], value T) error
- func (l *LinkedList[T]) Len() int
- func (l *LinkedList[T]) Remove(value T) error
- func (l *LinkedList[T]) RemoveTail() error
- func (l *LinkedList[T]) String() string
- type Node
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNodeNotFound = errors.New("node not found") ErrValueNotFound = errors.New("value not found") )
Functions ¶
func DisplayList ¶
DisplayList prints the elements of the linked list
func SortLinkedList ¶
func SortLinkedList[T any](ll *LinkedList[T], less func(i, j T) bool)
func SortLinkedListIterative ¶
func SortLinkedListIterative[T any](ll *LinkedList[T], less func(i, j T) bool)
Types ¶
type Compariable ¶
type Compariable interface {
Compare(interface{}) int
}
type LinkedList ¶
type LinkedList[T any] struct { Head *Node[T] Tail *Node[T] // contains filtered or unexported fields }
func (*LinkedList[T]) Contains ¶
func (l *LinkedList[T]) Contains(value T) bool
Contains returns true if the linked list contains the given value.
func (*LinkedList[T]) Empty ¶
func (l *LinkedList[T]) Empty() bool
Empty returns true if the linked list is empty.
func (*LinkedList[T]) Insert ¶
func (l *LinkedList[T]) Insert(value T)
Insert inserts a new node at the end of the linked list.
func (*LinkedList[T]) InsertBefore ¶
func (l *LinkedList[T]) InsertBefore(node *Node[T], value T) error
InsertBefore inserts a new node with the specififed value, before the given node.
func (*LinkedList[T]) Len ¶
func (l *LinkedList[T]) Len() int
Len returns the length of the linked list.
func (*LinkedList[T]) Remove ¶
func (l *LinkedList[T]) Remove(value T) error
Remove removes the given node from the linked list.
func (*LinkedList[T]) RemoveTail ¶
func (l *LinkedList[T]) RemoveTail() error
RemoveTail removes the last node from the linked list.
func (*LinkedList[T]) String ¶
func (l *LinkedList[T]) String() string
String returns a string representation of the linked list.
Click to show internal directories.
Click to hide internal directories.