Documentation
¶
Index ¶
- type Node
- type Sll
- func (list *Sll) Append(payload interface{}) *Node
- func (list *Sll) Clear()
- func (list *Sll) Get(index int) (*Node, bool)
- func (list *Sll) IndexOf(payload interface{}) (int, bool)
- func (list *Sll) InsertAfter(referenceNode *Node, payload interface{}) (*Node, bool)
- func (list *Sll) InsertAt(index int, payload interface{}) (*Node, bool)
- func (list *Sll) InsertBefore(referenceNode *Node, payload interface{}) (*Node, bool)
- func (list *Sll) Length() int
- func (list *Sll) Prepend(payload interface{}) *Node
- func (list *Sll) Print()
- func (list *Sll) RemoveByIndex(index int) (interface{}, bool)
- func (list *Sll) RemoveByNode(nodeToBeRemoved *Node) (interface{}, bool)
- func (list *Sll) ReplaceByIndex(index int, payload interface{}) (interface{}, *Node, bool)
- func (list *Sll) ReplaceByNode(nodeToBeReplaced *Node, payload interface{}) (interface{}, *Node, bool)
- func (list *Sll) ToSlice() []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
Payload interface{}
// contains filtered or unexported fields
}
Node : A struct describing the node, has Payload and a pointer to the next node in the list
type Sll ¶
Sll : A singly linked list which hols the elements
func (*Sll) IndexOf ¶
IndexOf : Finds first occurance given payload in the list, if found returns its index else -1
func (*Sll) InsertAfter ¶
InsertAfter : Insert a node after a given node. Returns pointer to newly inserted node, ok
func (*Sll) InsertAt ¶
InsertAt : Insert a node at at particular index, the current node at that index gets shifted. 0 <= index < length. Returns pointer to newly inserted node, ok
func (*Sll) InsertBefore ¶
InsertBefore : Insert a node before a given node. Returns pointer to newly inserted node, ok
func (*Sll) Print ¶
func (list *Sll) Print()
Print : Print the list in using fmt.Println canbe used for debugging
func (*Sll) RemoveByIndex ¶
RemoveByIndex : Remove node from specified index
func (*Sll) RemoveByNode ¶
RemoveByNode : Remove a node from the list based on its reference, returns node's payload, ok
func (*Sll) ReplaceByIndex ¶
ReplaceByIndex : Replace a node with a new node created with a given payload dpending upon the index. Returns the old node payload, newly created node, ok