Documentation
¶
Index ¶
- Variables
- func ArgumentNilError(arg string) error
- func NewError(err ErrNo) error
- func NewErrorDetailed(err ErrNo, msg string) error
- type BoolKey
- type ByteKey
- type DeleteEvent
- type ErrNo
- type Float32Key
- type Float64Key
- type InsertEvent
- type Int8Key
- type Int16Key
- type Int32Key
- type Int64Key
- type IntKey
- type KeyComparison
- type NilKey
- type RbIterationCallback
- type RbIterator
- type RbKey
- type RbTree
- func (tree *RbTree) Ceiling(key RbKey) (RbKey, interface{})
- func (tree *RbTree) Count() int
- func (tree *RbTree) Delete(key RbKey)
- func (tree *RbTree) Exists(key RbKey) bool
- func (tree *RbTree) Floor(key RbKey) (RbKey, interface{})
- func (tree *RbTree) Get(key RbKey) (interface{}, bool)
- func (tree *RbTree) Insert(key RbKey, value interface{})
- func (tree *RbTree) IsEmpty() bool
- func (tree *RbTree) Max() (RbKey, interface{})
- func (tree *RbTree) Min() (RbKey, interface{})
- func (tree *RbTree) NewRbIterator(callback RbIterationCallback) (RbIterator, error)
- type StringKey
- type Uint8Key
- type Uint16Key
- type Uint32Key
- type Uint64Key
- type UintKey
Constants ¶
This section is empty.
Variables ¶
var ( // ErrArgumentNil used if the function parameter is nil ErrArgumentNil = NewError(ErrNoArgumentNil) // ErrEnumeratorModified is used when the tree gets modified while iterating ErrEnumeratorModified = NewError(ErrNoEnumeratorModified) // ErrIteratorAlreadyRunning used if the iterator is already iterating ErrIteratorAlreadyRunning = NewError(ErrNoIteratorAlreadyRunning) // ErrIteratorClosed used if the iterator is closed ErrIteratorClosed = NewError(ErrNoIteratorClosed) // ErrIteratorUninitialized used if the iterator is uninitialized ErrIteratorUninitialized = NewError(ErrNoIteratorUninitialized) )
Functions ¶
func ArgumentNilError ¶
ArgumentNilError creates a new error with ErrNoArgumentNilWithName error no and named function parameter
func NewErrorDetailed ¶
NewErrorDetailed creates a new error with the given error no and message
Types ¶
type BoolKey ¶
type BoolKey bool
BoolKey is the boolean key for RbKey
func (*BoolKey) ComparedTo ¶
func (bkey *BoolKey) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type ByteKey ¶
type ByteKey byte
ByteKey is the byte key for RbKey
func (*ByteKey) ComparedTo ¶
func (bkey *ByteKey) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type DeleteEvent ¶
type DeleteEvent func(key RbKey, oldValue interface{}) (updatedValue interface{})
DeleteEvent function used on Insert or Delete operations
type ErrNo ¶
type ErrNo uintptr
ErrNo struct is used for the error code of the error
const ( // ErrNoArgumentNil is used if the function parameter is nil ErrNoArgumentNil ErrNo = iota + 1 // ErrNoArgumentNilWithName is used if the named function parameter is nil ErrNoArgumentNilWithName // ErrNoEnumeratorModified is used when the tree gets modified while iterating ErrNoEnumeratorModified // ErrNoIteratorAlreadyRunning is used if the iterator is already running ErrNoIteratorAlreadyRunning // ErrNoIteratorClosed is used if the iterator is closed ErrNoIteratorClosed // ErrNoIteratorUninitialized is used if the iterator is uninitialized ErrNoIteratorUninitialized )
type Float32Key ¶
type Float32Key float32
Float32Key is the float32 key for RbKey
func (*Float32Key) ComparedTo ¶
func (fkey *Float32Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Float64Key ¶
type Float64Key float64
Float64Key is the float64 key for RbKey
func (*Float64Key) ComparedTo ¶
func (fkey *Float64Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type InsertEvent ¶
type InsertEvent func(key RbKey, oldValue interface{}, newValue interface{}) (updatedValue interface{})
InsertEvent function used on Insert or Delete operations
type Int8Key ¶
type Int8Key int8
Int8Key is the int8 key for RbKey
func (*Int8Key) ComparedTo ¶
func (ikey *Int8Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Int16Key ¶
type Int16Key int16
Int16Key is the int16 key for RbKey
func (*Int16Key) ComparedTo ¶
func (ikey *Int16Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Int32Key ¶
type Int32Key int32
Int32Key is the int32 key for RbKey
func (*Int32Key) ComparedTo ¶
func (ikey *Int32Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Int64Key ¶
type Int64Key int64
Int64Key is the int64 key for RbKey
func (*Int64Key) ComparedTo ¶
func (ikey *Int64Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type IntKey ¶
type IntKey int
IntKey is the integer key for RbKey
func (*IntKey) ComparedTo ¶
func (ikey *IntKey) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type KeyComparison ¶
type KeyComparison int8
KeyComparison structure used as result of comparing two keys
const ( // KeyIsLess is returned as result of key comparison if the first key is less than the second key KeyIsLess KeyComparison = iota - 1 // KeysAreEqual is returned as result of key comparison if the first key is equal to the second key KeysAreEqual // KeyIsGreater is returned as result of key comparison if the first key is greater than the second key KeyIsGreater )
func (KeyComparison) String ¶
func (tree KeyComparison) String() string
type NilKey ¶
type NilKey struct{}
NilKey is the nil value key for RbKey
func (*NilKey) ComparedTo ¶
func (nkey *NilKey) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type RbIterationCallback ¶
type RbIterationCallback func(iterator RbIterator, key RbKey, value interface{})
RbIterationCallback is the function used to by the RbIterator with will be called on iteration match
type RbIterator ¶
type RbIterator interface {
// All iterates on all items of the RbTree
All() (int, error)
// Between iterates on the items of the RbTree that the key of the item
// is less or equal to loKey and greater or equal to hiKey
Between(loKey RbKey, hiKey RbKey) (int, error)
// ClearData clears all the data stored on the iterator
ClearData()
// Close closes the current iteration, so the iteration stops iterating
Close()
// Closed gives the state of the iterator, 'true' if closed
Closed() bool
// CurrentCount gives the count of the items that match the iteration case
CurrentCount() int
// LessOrEqual iterates on the items of the RbTree that the key of the item
// is less or equal to the given key
LessOrEqual(key RbKey) (int, error)
// LessThan iterates on the items of the RbTree that the key of the item
// is less than the given key
LessThan(key RbKey) (int, error)
// GetData returns the data stored on the iterator with the dataKey
GetData(dataKey string) (interface{}, bool)
// GreaterOrEqual iterates on the items of the RbTree that the key of the item
// is greater or equal to the given key
GreaterOrEqual(key RbKey) (int, error)
// GreaterThan iterates on the items of the RbTree that the key of the item
// is greater than the given key
GreaterThan(key RbKey) (int, error)
// RemoveData deletes the data stored on the iterator with the dataKey
RemoveData(dataKey string)
// SetData stores the data with the dataKey on the iterator
SetData(dataKey string, value interface{})
// Tree returns the RbTree that the iterator is iterating on
Tree() *RbTree
}
RbIterator interface used for iterating on a RbTree
type RbTree ¶
type RbTree struct {
// contains filtered or unexported fields
}
RbTree structure
func NewRbTreeWithEvents ¶
func NewRbTreeWithEvents(onInsert InsertEvent, onDelete DeleteEvent) *RbTree
NewRbTreeWithEvents creates a new RbTree assigning its insert and delete events and returns its address
func (*RbTree) Get ¶
Get returns the stored value if key found and 'true', otherwise returns 'false' with second return param if key not found
func (*RbTree) NewRbIterator ¶
func (tree *RbTree) NewRbIterator(callback RbIterationCallback) (RbIterator, error)
NewRbIterator creates a new iterator for the given RbTree
type StringKey ¶
type StringKey string
StringKey is the string key for RbKey
func (*StringKey) ComparedTo ¶
func (skey *StringKey) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Uint8Key ¶
type Uint8Key uint8
Uint8Key is the uint8 key for RbKey
func (*Uint8Key) ComparedTo ¶
func (ikey *Uint8Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Uint16Key ¶
type Uint16Key uint16
Uint16Key is the uint16 key for RbKey
func (*Uint16Key) ComparedTo ¶
func (ikey *Uint16Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Uint32Key ¶
type Uint32Key uint32
Uint32Key is the uint32 key for RbKey
func (*Uint32Key) ComparedTo ¶
func (ikey *Uint32Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type Uint64Key ¶
type Uint64Key uint64
Uint64Key is the uint64 key for RbKey
func (*Uint64Key) ComparedTo ¶
func (ikey *Uint64Key) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self
type UintKey ¶
type UintKey uint
UintKey is the uint key for RbKey
func (*UintKey) ComparedTo ¶
func (ikey *UintKey) ComparedTo(key RbKey) KeyComparison
ComparedTo compares the given RbKey with its self