list

package
v0.0.0-...-feced46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintList

func PrintList(l List)

Types

type DNode

type DNode struct {
	Value interface{}
	Next  *DNode
	Prev  *DNode
}

type Double

type Double struct {
	Size int
	// contains filtered or unexported fields
}

func (*Double) Add

func (d *Double) Add(e interface{}) (int, error)

func (*Double) Delete

func (d *Double) Delete(e interface{}) error

func (*Double) ReverseTraverse

func (d *Double) ReverseTraverse() []interface{}

func (*Double) Traverse

func (d *Double) Traverse() []interface{}

type List

type List interface {
	Add(interface{}) (int, error)
	Delete(interface{}) error
	//Search(interface{}) (int, error)
	Traverse() []interface{}
}

type Node

type Node struct {
	Value interface{}
	Next  *Node
}

type Single

type Single struct {
	Size int
	// contains filtered or unexported fields
}

func (*Single) Add

func (s *Single) Add(element interface{}) error

Add recives an element and inserts it to the end of the linked list

func (*Single) Delete

func (s *Single) Delete(element interface{}) error

Delete will delete the first node it maches It will return an error if the list is empty, or if the element was not in the list

func (*Single) ReverseTraverse

func (s *Single) ReverseTraverse() []interface{}

ReverseTraverse returns an array of the linked list in a reversed order.

func (*Single) Search

func (s *Single) Search(element interface{}) (int, error)

Search will search an element in the linked list and returns the index of the first match it finds. If the list is empty or the element is not in the list, it will return an error

func (*Single) Traverse

func (s *Single) Traverse() []interface{}

Traverse returns an array of all the elements in the linked list

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL