-- import "linkedlist"
type IndexOutOfRangeError struct {
}
An error that occurs when trying to access an index out of bounds
func (e *IndexOutOfRangeError) Error() string
Returns an error message for IndexOutOfRangeError
type LinkedList struct {
sync.RWMutex
}
A representation of a Doubly-LinkedList
func NewLinkedList() *LinkedList
Initializes a new empty LinkedList
func (ll *LinkedList) Clear()
Removes all values from the list
func (ll *LinkedList) Filter(predicate func(interface{}, uint) bool) *LinkedList
Applies the predicate to all items in the list and returns a new list of all values that satisfy the predicate.
func (ll *LinkedList) Get(index uint) interface{}
Returns a value stored at the given index in the list or nil if no item exists at the given index
func (ll *LinkedList) Head() interface{}
Returns the first element in the list or nil if the list is empty
func (ll *LinkedList) Map(fn func(interface{}, uint) interface{}) *LinkedList
Maps over all values in the list and creates a new list of mapped values
func (ll *LinkedList) Pop() interface{}
Removes the item at the BEGINNING of the list and returns it
func (ll *LinkedList) PopBack() interface{}
Removes the item at the END of the list and returns it
func (ll *LinkedList) Push(data interface{})
Adds a new item at the BEGINNING of the list
func (ll *LinkedList) PushBack(data interface{})
Adds a new item to the END of the list
func (ll *LinkedList) Remove(index uint) interface{}
Removes an item at a given position in the list and returns it
func (ll *LinkedList) Set(index uint, data interface{})
Replaces the value of an existing item in the list
func (ll *LinkedList) Size() uint
Returns the number of items stored in the list
func (ll *LinkedList) Tail() interface{}
Returns the last element in the list or nil if the list is empty
type LinkedListNode struct {
}
A Node within a LinkedList