Documentation ¶
Overview ¶
Package al implements classical algorithms such as Queue, Stack and others
Package al implements classical algorithms such as Queue, Stack and others ¶
Package al implements classical algorithms such as Queue, Stack and others
Index ¶
- func Float64Comparator(a, b float64) int
- func Float64RecQuickSort(A []float64, compare func(a, b float64) int)
- func Float64RecQuickSortNonOpt(A []float64, compare func(a, b float64) int)
- func IntComparator(a, b int) int
- func IntRecQuickSort(A []int, compare func(a, b int) int)
- func IntRecQuickSortNonOpt(A []int, compare func(a, b int) int)
- func StringComparator(a, b string) int
- func StringRecQuickSort(A []string, compare func(a, b string) int)
- func StringRecQuickSortNonOpt(A []string, compare func(a, b string) int)
- type Float64LinkedList
- func (o *Float64LinkedList) Find(condition func(node *Float64LinkedNode) bool) (found *Float64LinkedNode)
- func (o *Float64LinkedList) Insert(data float64) (newNode *Float64LinkedNode)
- func (o *Float64LinkedList) Remove(node *Float64LinkedNode)
- func (o *Float64LinkedList) String() (l string)
- func (o *Float64LinkedList) Traverse(action func(node *Float64LinkedNode) (stop bool))
- type Float64LinkedNode
- type Float64Queue
- type IntLinkedList
- func (o *IntLinkedList) Find(condition func(node *IntLinkedNode) bool) (found *IntLinkedNode)
- func (o *IntLinkedList) Insert(data int) (newNode *IntLinkedNode)
- func (o *IntLinkedList) Remove(node *IntLinkedNode)
- func (o *IntLinkedList) String() (l string)
- func (o *IntLinkedList) Traverse(action func(node *IntLinkedNode) (stop bool))
- type IntLinkedNode
- type IntQueue
- type StringLinkedList
- func (o *StringLinkedList) Find(condition func(node *StringLinkedNode) bool) (found *StringLinkedNode)
- func (o *StringLinkedList) Insert(data string) (newNode *StringLinkedNode)
- func (o *StringLinkedList) Remove(node *StringLinkedNode)
- func (o *StringLinkedList) String() (l string)
- func (o *StringLinkedList) Traverse(action func(node *StringLinkedNode) (stop bool))
- type StringLinkedNode
- type StringQueue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float64Comparator ¶
Float64Comparator compares float64s
func Float64RecQuickSort ¶
Float64RecQuickSort is a Recursive (Naive) implementation of the quicksort algorithm (Hoare version)
compare -- returns: +1 if a > b 0 if a == b -1 if a < b Note: recursive version
func Float64RecQuickSortNonOpt ¶
Float64RecQuickSortNonOpt is the non-optimal version of Float64RecQuickSort
func IntRecQuickSort ¶
IntRecQuickSort is a Recursive (Naive) implementation of the quicksort algorithm (Hoare version)
compare -- returns: +1 if a > b 0 if a == b -1 if a < b Note: recursive version
func IntRecQuickSortNonOpt ¶
IntRecQuickSortNonOpt is the non-optimal version of IntRecQuickSort
func StringComparator ¶
StringComparator compares strings lexicographically (lexicographical order)
func StringRecQuickSort ¶
StringRecQuickSort is a Recursive (Naive) implementation of the quicksort algorithm (Hoare version)
compare -- returns: +1 if a > b 0 if a == b -1 if a < b Note: recursive version
func StringRecQuickSortNonOpt ¶
StringRecQuickSortNonOpt is the non-optimal version of StringRecQuickSort
Types ¶
type Float64LinkedList ¶
type Float64LinkedList struct {
// contains filtered or unexported fields
}
Float64LinkedList defines Doubly Linked List
func NewFloat64LinkedList ¶
func NewFloat64LinkedList() (o *Float64LinkedList)
NewFloat64LinkedList returns a new Doubly Linked List object
func (*Float64LinkedList) Find ¶
func (o *Float64LinkedList) Find(condition func(node *Float64LinkedNode) bool) (found *Float64LinkedNode)
Find finds a node by traversing the list and comparing a to b
func (*Float64LinkedList) Insert ¶
func (o *Float64LinkedList) Insert(data float64) (newNode *Float64LinkedNode)
Insert inserts data just after root and returns the inserted node
func (*Float64LinkedList) Remove ¶
func (o *Float64LinkedList) Remove(node *Float64LinkedNode)
Remove removes node from Doubly Linked List
func (*Float64LinkedList) String ¶
func (o *Float64LinkedList) String() (l string)
String returns a string representation of this list, after traversing all nodes
func (*Float64LinkedList) Traverse ¶
func (o *Float64LinkedList) Traverse(action func(node *Float64LinkedNode) (stop bool))
Traverse traverses the Doubly Linked List and executes action(node) Note action(node) may never be called if there aren't any nodes in the list
type Float64LinkedNode ¶
type Float64LinkedNode struct { Data *float64 // contains filtered or unexported fields }
Float64LinkedNode defines a node in a Doubly Linked List
type Float64Queue ¶
type Float64Queue struct { Debug bool // debug flag // contains filtered or unexported fields }
Float64Queue implements a FIFO queue, a sequence where the first inserted will be the first removed. Think of arriving people at the Bank or DMV...
func NewFloat64Queue ¶
func NewFloat64Queue(guessedBufferSize int) (o *Float64Queue)
NewFloat64Queue returns a new object
func (*Float64Queue) Back ¶
func (o *Float64Queue) Back() *float64
Back returns the member @ back (unlucky guy/girl...) or nil if empty. It is always the last item in the data array
func (*Float64Queue) Front ¶
func (o *Float64Queue) Front() *float64
Front returns the member @ front of queue (close to the DMV window...) or nil if empty
func (*Float64Queue) In ¶
func (o *Float64Queue) In(member float64)
In receives a new member arrival TODO: implement use of different grow rates
func (*Float64Queue) Nmembers ¶
func (o *Float64Queue) Nmembers() int
Nmembers returns the length of queue; i.e. the number of members
func (*Float64Queue) Out ¶
func (o *Float64Queue) Out() (member *float64)
Out removes the member @ front and returns a pointer to him/her TODO: implement memory recovery
func (*Float64Queue) String ¶
func (o *Float64Queue) String() (l string)
String returns the string representation of this object
type IntLinkedList ¶
type IntLinkedList struct {
// contains filtered or unexported fields
}
IntLinkedList defines Doubly Linked List
func NewIntLinkedList ¶
func NewIntLinkedList() (o *IntLinkedList)
NewIntLinkedList returns a new Doubly Linked List object
func (*IntLinkedList) Find ¶
func (o *IntLinkedList) Find(condition func(node *IntLinkedNode) bool) (found *IntLinkedNode)
Find finds a node by traversing the list and comparing a to b
func (*IntLinkedList) Insert ¶
func (o *IntLinkedList) Insert(data int) (newNode *IntLinkedNode)
Insert inserts data just after root and returns the inserted node
func (*IntLinkedList) Remove ¶
func (o *IntLinkedList) Remove(node *IntLinkedNode)
Remove removes node from Doubly Linked List
func (*IntLinkedList) String ¶
func (o *IntLinkedList) String() (l string)
String returns a string representation of this list, after traversing all nodes
func (*IntLinkedList) Traverse ¶
func (o *IntLinkedList) Traverse(action func(node *IntLinkedNode) (stop bool))
Traverse traverses the Doubly Linked List and executes action(node) Note action(node) may never be called if there aren't any nodes in the list
type IntLinkedNode ¶
type IntLinkedNode struct { Data *int // contains filtered or unexported fields }
IntLinkedNode defines a node in a Doubly Linked List
type IntQueue ¶
type IntQueue struct { Debug bool // debug flag // contains filtered or unexported fields }
IntQueue implements a FIFO queue, a sequence where the first inserted will be the first removed. Think of arriving people at the Bank or DMV...
func NewIntQueue ¶
NewIntQueue returns a new object
func (*IntQueue) Back ¶
Back returns the member @ back (unlucky guy/girl...) or nil if empty. It is always the last item in the data array
func (*IntQueue) Front ¶
Front returns the member @ front of queue (close to the DMV window...) or nil if empty
type StringLinkedList ¶
type StringLinkedList struct {
// contains filtered or unexported fields
}
StringLinkedList defines Doubly Linked List
func NewStringLinkedList ¶
func NewStringLinkedList() (o *StringLinkedList)
NewStringLinkedList returns a new Doubly Linked List object
func (*StringLinkedList) Find ¶
func (o *StringLinkedList) Find(condition func(node *StringLinkedNode) bool) (found *StringLinkedNode)
Find finds a node by traversing the list and comparing a to b
func (*StringLinkedList) Insert ¶
func (o *StringLinkedList) Insert(data string) (newNode *StringLinkedNode)
Insert inserts data just after root and returns the inserted node
func (*StringLinkedList) Remove ¶
func (o *StringLinkedList) Remove(node *StringLinkedNode)
Remove removes node from Doubly Linked List
func (*StringLinkedList) String ¶
func (o *StringLinkedList) String() (l string)
String returns a string representation of this list, after traversing all nodes
func (*StringLinkedList) Traverse ¶
func (o *StringLinkedList) Traverse(action func(node *StringLinkedNode) (stop bool))
Traverse traverses the Doubly Linked List and executes action(node) Note action(node) may never be called if there aren't any nodes in the list
type StringLinkedNode ¶
type StringLinkedNode struct { Data *string // contains filtered or unexported fields }
StringLinkedNode defines a node in a Doubly Linked List
type StringQueue ¶
type StringQueue struct { Debug bool // debug flag // contains filtered or unexported fields }
StringQueue implements a FIFO queue, a sequence where the first inserted will be the first removed. Think of arriving people at the Bank or DMV...
func NewStringQueue ¶
func NewStringQueue(guessedBufferSize int) (o *StringQueue)
NewStringQueue returns a new object
func (*StringQueue) Back ¶
func (o *StringQueue) Back() *string
Back returns the member @ back (unlucky guy/girl...) or nil if empty. It is always the last item in the data array
func (*StringQueue) Front ¶
func (o *StringQueue) Front() *string
Front returns the member @ front of queue (close to the DMV window...) or nil if empty
func (*StringQueue) In ¶
func (o *StringQueue) In(member string)
In receives a new member arrival TODO: implement use of different grow rates
func (*StringQueue) Nmembers ¶
func (o *StringQueue) Nmembers() int
Nmembers returns the length of queue; i.e. the number of members
func (*StringQueue) Out ¶
func (o *StringQueue) Out() (member *string)
Out removes the member @ front and returns a pointer to him/her TODO: implement memory recovery
func (*StringQueue) String ¶
func (o *StringQueue) String() (l string)
String returns the string representation of this object