Documentation ¶
Index ¶
- type LinkedList
- func (c *LinkedList[T]) AddFirst(data T)
- func (c *LinkedList[T]) AddLast(data T)
- func (c *LinkedList[T]) First() (data T, ok bool)
- func (c *LinkedList[T]) IsEmpty() bool
- func (c *LinkedList[T]) Last() (data T, ok bool)
- func (c *LinkedList[T]) RemoveFirst() (val T, ok bool)
- func (c *LinkedList[T]) RemoveLast() (val T, ok bool)
- func (c *LinkedList[T]) Rotate()
- func (c *LinkedList[T]) String() string
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LinkedList ¶
func New ¶
func New[T any]() LinkedList[T]
New constructs and returns an empty circularly linked-list. time-complexity: O(1)
func (*LinkedList[T]) AddFirst ¶
func (c *LinkedList[T]) AddFirst(data T)
AddFirst adds a new node to the beginning of the list. time-complexity: O(1)
func (*LinkedList[T]) AddLast ¶
func (c *LinkedList[T]) AddLast(data T)
AddLast adds a new node to the end of the list. time-complexity: O(1)
func (*LinkedList[T]) First ¶
func (c *LinkedList[T]) First() (data T, ok bool)
First returns the first element of the list. It returns false if the list is empty. time-complexity: O(1)
func (*LinkedList[T]) IsEmpty ¶
func (c *LinkedList[T]) IsEmpty() bool
IsEmpty returns true if the linked-list doesn't contain any nodes. time-complexity: O(1)
func (*LinkedList[T]) Last ¶
func (c *LinkedList[T]) Last() (data T, ok bool)
Last returns the last element of the list. It returns false if the list is empty. time-complexity: O(1)
func (*LinkedList[T]) RemoveFirst ¶
func (c *LinkedList[T]) RemoveFirst() (val T, ok bool)
RemoveFirst removes and returns the first element of the list. It returns false if the list is empty. time-complexity: O(1)
func (*LinkedList[T]) RemoveLast ¶
func (c *LinkedList[T]) RemoveLast() (val T, ok bool)
RemoveLast removes and returns the last element of the list. It returns false if the list empty. time-complexity: O(n)
func (*LinkedList[T]) Rotate ¶
func (c *LinkedList[T]) Rotate()
Rotate rotates the list. It moves the first element to the end. time-complexity: O(1)
func (*LinkedList[T]) String ¶
func (c *LinkedList[T]) String() string
String returns the string representation of the list. time-complexity: O(n)