Documentation ¶
Index ¶
- func NewEmptyListError() errors.TracerError
- func NewListNonEmptyError() errors.TracerError
- func NewNoElementError() errors.TracerError
- func NewNoMemberError() errors.TracerError
- type DList
- type DListElement
- type EmptyListError
- type Index
- type Indexable
- type Indexer
- type List
- type ListElement
- type ListNonEmptyError
- type NoElementError
- type NoMemberError
- type Queue
- type Set
- type Stack
- type StringQueue
- type StringSet
- type StringStack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEmptyListError ¶
func NewEmptyListError() errors.TracerError
NewEmptyListError instantiates a EmptyListError with a stack trace
func NewListNonEmptyError ¶
func NewListNonEmptyError() errors.TracerError
NewListNonEmptyError instantiates a ListNonEmptyError with a stack trace
func NewNoElementError ¶
func NewNoElementError() errors.TracerError
NewNoElementError instantiates a NoElementError with a stack trace
func NewNoMemberError ¶
func NewNoMemberError() errors.TracerError
NewNoMemberError instantiates a NoMemberError with a stack trace
Types ¶
type DList ¶
type DList interface { // Size of the this dlist as a count of the elements in it. Size() int // Head of the list. Head() *DListElement // IsHead of the list. IsHead(element *DListElement) bool // Tail of the list. Tail() *DListElement // IsTail of the list. IsTail(element *DListElement) bool // InsertNext inserts the passed data after the passed element. If the list is empty a 'nil' element is allowed // otherwise an error will be returned. InsertNext(element *DListElement, data interface{}) (*DListElement, error) // InsertPrevious inserts the passed data before the passed element in the list. If the list is empty a 'nil' element // is allowed, otherwise an error will be returned. InsertPrevious(element *DListElement, data interface{}) (*DListElement, error) // Remove the element from the list. Remove(element *DListElement) (data interface{}, err error) }
DList is an implementation of a doubly linked list data structure.
type DListElement ¶
type DListElement struct {
// contains filtered or unexported fields
}
DListElement is the primary element for use inside of a DList
func (DListElement) Next ¶
func (element DListElement) Next() *DListElement
Next element in the DList.
func (DListElement) Previous ¶
func (element DListElement) Previous() *DListElement
Previous element in the Dlist
type EmptyListError ¶
type EmptyListError struct {
// contains filtered or unexported fields
}
EmptyListError is returned when a operation is called on an empty list that requires at least one element in the list.
func (*EmptyListError) Error ¶
func (err *EmptyListError) Error() string
func (*EmptyListError) Trace ¶
func (err *EmptyListError) Trace() []string
Trace returns the stack trace for the error
type Index ¶
type Index interface { // Add the passed indexable to the index Add(obj Indexable) // Update the passed indexable in the index Update(obj Indexable) // Remove the passed indexable from the index (removed by ID) Remove(obj Indexable) // LookupValue in the index and return the ID's that correspond to it LookupValue(fieldValue interface{}) []string }
Index for a field on an Indexable
type Indexable ¶
Indexable provides the methods necessary for using an object in the indexing structures.
type Indexer ¶
type Indexer interface { // Index the field name for all objects added to this indexer Index(fieldName string) // Contains the passed id Contains(id string) bool // Add the passed indexable to all the indices Add(obj Indexable) // Remove the passed indexable from all indices Remove(obj Indexable) // Values in the indexes that have the fieldName assigned the fieldValue, returns // false if there is no index supporting the passed field name. Values(fieldName string, fieldValue interface{}) ([]Indexable, bool) // Get the indexable for the passed ID form this indexer. Get(id string) (Indexable, bool) // Count the number of distinct records in this indexer Count() int // Iterate all values in this indexer Iterate() []Indexable }
Indexer exposes methods that allow for indexing arbitrary fields on an object collection.
type List ¶
type List interface { // Head (first element) of the list. Head() *ListElement // Tail (last element) of the list. Tail() (element *ListElement) // IsHead returns a boolean indicating whether the passed element is the first element in the list. IsHead(element *ListElement) bool // IsTail returns a boolean indicating if the passed element is the last element in the list. IsTail(element *ListElement) bool // Size of the list (number of elements). Size() int // InsertNext data into the list after the passed element. If the element is nil, the data will be inserted at // the head of the list. InsertNext(element *ListElement, data interface{}) *ListElement // RemoveNext element from the list and return it's data. If passed element is 'nil' the head will be removed // from the list. RemoveNext(element *ListElement) (data interface{}, err error) }
List is a singly linked list implementation
type ListElement ¶
type ListElement struct {
// contains filtered or unexported fields
}
ListElement is a singly linked node in a list.
func (ListElement) Data ¶
func (listElement ListElement) Data() interface{}
Data returns the data contained in this element.
func (ListElement) Next ¶
func (listElement ListElement) Next() (element *ListElement)
Next returns the element the follows this element.
type ListNonEmptyError ¶
type ListNonEmptyError struct {
// contains filtered or unexported fields
}
ListNonEmptyError is returned when a empty list is required for the operation.
func (*ListNonEmptyError) Error ¶
func (err *ListNonEmptyError) Error() string
func (*ListNonEmptyError) Trace ¶
func (err *ListNonEmptyError) Trace() []string
Trace returns the stack trace for the error
type NoElementError ¶
type NoElementError struct {
// contains filtered or unexported fields
}
NoElementError is returned when an operation that requires an element is called when no element is present at that position.
func (*NoElementError) Error ¶
func (err *NoElementError) Error() string
func (*NoElementError) Trace ¶
func (err *NoElementError) Trace() []string
Trace returns the stack trace for the error
type NoMemberError ¶
type NoMemberError struct {
// contains filtered or unexported fields
}
NoMemberError is returned when an element is passed that is not a member of a list.
func (*NoMemberError) Error ¶
func (err *NoMemberError) Error() string
func (*NoMemberError) Trace ¶
func (err *NoMemberError) Trace() []string
Trace returns the stack trace for the error
type Queue ¶
type Queue interface { // Size of the queue represented as a count of the elements in the queue. Size() int // Push a new data element onto the queue. Push(data interface{}) // Pop the most recently pushed data element off the queue. Pop() (interface{}, error) // Peek returns the most recently pushed element without modifying the queue Peek() (interface{}, error) }
Queue is an implementation of a queue (fifo) data structure
type Set ¶
type Set interface { // Add the passed objects to the set Add(objs ...interface{}) Set // Remove the passed objects from the set Remove(objs ...interface{}) Set // Contains the passed object Contains(interface{}) bool // Elements in this set Elements() []interface{} // Size of this set (number of elements) Size() int // New set of the same type as this set New() Set }
Set data structure methods.
func Disjunction ¶
Disjunction of sets a and b as a new set of the same type as a.
func Intersection ¶
Intersection of sets a and b as a new set of the same type as a.
type Stack ¶
type Stack interface { // Size of the stack represented as a count of the elements in the stack. Size() int // Push a new data element onto the stack. Push(data interface{}) // Pop the most recently pushed data element off the stack. Pop() (interface{}, error) // Peek returns the most recently pushed element without modifying the stack Peek() (interface{}, error) }
Stack is an implementation of a stack (filo/lifo) datastructure
type StringQueue ¶
type StringQueue interface { // Size of the queue represented as a count of the elements in the queue. Size() int // Push a new data element onto the queue. Push(data string) // Pop the most recently pushed data element off the queue. Pop() (string, error) // Peek returns the most recently pushed element without modifying the queue Peek() (string, error) }
StringQueue is a queue implementation that can only store strings.
type StringSet ¶
type StringSet interface { // Add the passed objects to the set Add(objs ...string) StringSet // Remove the passed objects from the set Remove(objs ...string) StringSet // Contains the passed object Contains(string) bool // Elements in this set Elements() []string // Size of this set (number of elements) Size() int // New set of the same type as this set New() StringSet }
StringSet is self explanatory
func NewStringSet ¶
NewStringSet containing the passed strings.
type StringStack ¶
type StringStack interface { // Size of the stack represented as a count of the elements in the stack. Size() int // Push a new data element onto the stack. Push(data string) // Pop the most recently pushed data element off the stack. Pop() (string, error) // Peek returns the most recently pushed element without modifying the stack Peek() (string, error) }
StringStack is a stack for storing strings.
func NewStringStack ¶
func NewStringStack() StringStack
NewStringStack that is empty and ready to use.
func NewStringStackFromStack ¶
func NewStringStackFromStack(stack Stack) StringStack
NewStringStackFromStack allows for specifying the base of the string stack.