Documentation ¶
Index ¶
- Variables
- type Sll
- func (ns *Sll[T]) Current(el *SllElement[T], pos int) *SllIter[T]
- func (ns *Sll[T]) Delete(it *SllElement[T]) (err error)
- func (ns *Sll[T]) Front() *SllIter[T]
- func (ns *Sll[T]) InsertAfterTail(t *T)
- func (ns *Sll[T]) InsertBeforeHead(t *T)
- func (ns *Sll[T]) IsEmpty() bool
- func (ns *Sll[T]) Length() int
- func (ns *Sll[T]) Peek() (rv *T, err error)
- func (ns *Sll[T]) Pop() (rv *T, err error)
- func (ns *Sll[T]) Push(t *T)
- func (ns *Sll[T]) Search(t *T) (rv *SllElement[T], pos int)
- func (ns *Sll[T]) Truncate()
- type SllElement
- type SllIter
Constants ¶
This section is empty.
Variables ¶
var ErrEmptySll = errors.New("Empty Sll")
An error to indicate that the stack is empty
Functions ¶
This section is empty.
Types ¶
type Sll ¶
type Sll[T comparable.Equality] struct { // contains filtered or unexported fields }
Sll is a generic type buildt on top of a slice
func NewSll ¶
func NewSll[T comparable.Equality]() *Sll[T]
Create a new SLL and return it. Complexity is O(1).
func (*Sll[T]) Current ¶
func (ns *Sll[T]) Current(el *SllElement[T], pos int) *SllIter[T]
Current will take the node returned from Search or RevrseSearch
func (ns *Sll[T]) Search( t *T ) (rv *SllElement[T], pos int) {
and allow you to start an iteration process from that point.
func (*Sll[T]) Delete ¶
func (ns *Sll[T]) Delete(it *SllElement[T]) (err error)
func (*Sll[T]) InsertAfterTail ¶
func (ns *Sll[T]) InsertAfterTail(t *T)
InsertAfterTail will append a new node to the end of the list.
func (*Sll[T]) InsertBeforeHead ¶
func (ns *Sll[T]) InsertBeforeHead(t *T)
InsertHeadSLL will append a new node to the end of the list.
func (*Sll[T]) IsEmpty ¶
------------------------------------------------------------------------------------------------------- IsEmpty will return true if the stack is empty
func (*Sll[T]) Peek ¶
Peek returns the top element of the stack or an error indicating that the stack is empty.
func (*Sll[T]) Pop ¶
Pop will remove the top element from the stack. An error is returned if the stack is empty.
func (*Sll[T]) Push ¶
func (ns *Sll[T]) Push(t *T)
Push will append a new node to the end of the list.
func (*Sll[T]) Search ¶
func (ns *Sll[T]) Search(t *T) (rv *SllElement[T], pos int)
Search — Returns the given element from a linked list. Search is from head to tail. O(n)
type SllElement ¶
type SllElement[T comparable.Equality] struct { // contains filtered or unexported fields }
A node in the singly linked list
type SllIter ¶
type SllIter[T comparable.Equality] struct { // contains filtered or unexported fields }
An iteration type that allows a for loop to walk the list.
func (*SllIter[T]) Next ¶
func (iter *SllIter[T]) Next()
Next advances to the next element in the list.