Documentation ¶
Index ¶
- Variables
- type Sll
- func (ns *Sll[T]) Current(el *SllElement[T], pos int) *SllIter[T]
- func (ns *Sll[T]) Delete(t *T) (err error)
- func (ns *Sll[T]) DeleteFound(t *SllElement[T]) (err error)
- func (tt *Sll[T]) Dump(fp io.Writer)
- 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]) IterateOver() iter.Seq2[int, T]
- func (ns *Sll[T]) IteratePtr() iter.Seq2[int, *T]
- 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]) Reverse()
- 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
var ErrNotFound = errors.New("Not Found")
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]) DeleteFound ¶ added in v0.0.6
func (ns *Sll[T]) DeleteFound(t *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)
InsertBeforeHead 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. O(1)
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]) Reverse ¶ added in v0.0.15
func (ns *Sll[T]) Reverse()
Reverse - effeciently reverse direciotn on a list. O(n) with storage O(1)
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.