multi_index

package
v0.0.0-...-e0ee87b Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ByExpireCompare = func(a, b common.TimePoint) int {
	switch {
	case a > b:
		return 1
	case a < b:
		return -1
	default:
		return 0
	}
}
View Source
var ByExpiryFunc = func(n TransactionIdWithExpiry) common.TimePoint { return n.Expiry }
View Source
var ByIdFunc = func(n TransactionIdWithExpiry) common.TransactionIdType { return n.TrxId }

Functions

This section is empty.

Types

type ByExpiry

type ByExpiry struct {
	Root *ByExpiryNode
	// contains filtered or unexported fields
}

OrderedIndex holds elements of the red-black tree

func (*ByExpiry) Begin

func (tree *ByExpiry) Begin() IteratorByExpiry

func (*ByExpiry) Clear

func (tree *ByExpiry) Clear()

Clear removes all nodes from the tree.

func (*ByExpiry) Empty

func (tree *ByExpiry) Empty() bool

Empty returns true if tree does not contain any nodes

func (*ByExpiry) End

func (tree *ByExpiry) End() IteratorByExpiry

func (*ByExpiry) Erase

func (tree *ByExpiry) Erase(iter IteratorByExpiry) (itr IteratorByExpiry)

func (*ByExpiry) Erases

func (tree *ByExpiry) Erases(first, last IteratorByExpiry)

func (*ByExpiry) Find

func (tree *ByExpiry) Find(key common.TimePoint) IteratorByExpiry

Get searches the node in the tree by key and returns its value or nil if key is not found in tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByExpiry) Insert

func (*ByExpiry) Iterator

func (tree *ByExpiry) Iterator() IteratorByExpiry

Iterator returns a stateful iterator whose elements are key/value pairs.

func (*ByExpiry) Keys

func (tree *ByExpiry) Keys() []common.TimePoint

Keys returns all keys in-order

func (*ByExpiry) Left

func (tree *ByExpiry) Left() *ByExpiryNode

Left returns the left-most (min) node or nil if tree is empty.

func (*ByExpiry) LowerBound

func (tree *ByExpiry) LowerBound(key common.TimePoint) IteratorByExpiry

LowerBound returns an iterator pointing to the first element that is not less than the given key. Complexity: O(log N).

func (*ByExpiry) Modify

func (tree *ByExpiry) Modify(iter IteratorByExpiry, mod func(*TransactionIdWithExpiry)) bool

func (*ByExpiry) Remove

func (tree *ByExpiry) Remove(key common.TimePoint)

Remove remove the node from the tree by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*ByExpiry) Right

func (tree *ByExpiry) Right() *ByExpiryNode

Right returns the right-most (max) node or nil if tree is empty.

func (*ByExpiry) Size

func (tree *ByExpiry) Size() int

Size returns number of nodes in the tree.

func (*ByExpiry) String

func (tree *ByExpiry) String() string

String returns a string representation of container

func (*ByExpiry) UpperBound

func (tree *ByExpiry) UpperBound(key common.TimePoint) IteratorByExpiry

UpperBound returns an iterator pointing to the first element that is greater than the given key. Complexity: O(log N).

func (*ByExpiry) Values

func (tree *ByExpiry) Values() []TransactionIdWithExpiry

Values returns all values in-order based on the key.

type ByExpiryNode

type ByExpiryNode struct {
	Key common.TimePoint

	Left   *ByExpiryNode
	Right  *ByExpiryNode
	Parent *ByExpiryNode
	// contains filtered or unexported fields
}

OrderedIndexNode is a single element within the tree

func (*ByExpiryNode) String

func (node *ByExpiryNode) String() string

type ById

type ById struct {
	// contains filtered or unexported fields
}

func (*ById) Each

func (i *ById) Each(f func(key common.TransactionIdType, obj TransactionIdWithExpiry))

func (*ById) Empty

func (i *ById) Empty() bool

func (*ById) End

func (i *ById) End() IteratorById

func (*ById) Erase

func (i *ById) Erase(iter IteratorById)

func (*ById) Find

func (*ById) GetFinalIndex

func (i *ById) GetFinalIndex() interface{}

func (*ById) GetSuperIndex

func (i *ById) GetSuperIndex() interface{}

func (*ById) Insert

func (*ById) Modify

func (i *ById) Modify(iter IteratorById, mod func(*TransactionIdWithExpiry)) bool

func (*ById) Size

func (i *ById) Size() int

func (*ById) Values

func (i *ById) Values() []TransactionIdWithExpiry

type ByIdNode

type ByIdNode struct {
	// contains filtered or unexported fields
}

func (*ByIdNode) GetFinalNode

func (n *ByIdNode) GetFinalNode() interface{}

func (*ByIdNode) GetSuperNode

func (n *ByIdNode) GetSuperNode() interface{}

type IteratorByExpiry

type IteratorByExpiry struct {
	// contains filtered or unexported fields
}

Iterator holding the iterator's state

func (*IteratorByExpiry) Begin

func (iterator *IteratorByExpiry) Begin()

Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.

func (*IteratorByExpiry) Delete

func (iterator *IteratorByExpiry) Delete()

Delete remove the node which pointed by the iterator Modifies the state of the iterator.

func (*IteratorByExpiry) End

func (iterator *IteratorByExpiry) End()

End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.

func (IteratorByExpiry) HasNext

func (iterator IteratorByExpiry) HasNext() bool

func (*IteratorByExpiry) HasPrev

func (iterator *IteratorByExpiry) HasPrev() bool

func (IteratorByExpiry) IsBegin

func (iterator IteratorByExpiry) IsBegin() bool

func (IteratorByExpiry) IsEnd

func (iterator IteratorByExpiry) IsEnd() bool

func (IteratorByExpiry) Key

func (iterator IteratorByExpiry) Key() common.TimePoint

Key returns the current element's key. Does not modify the state of the iterator.

func (*IteratorByExpiry) Next

func (iterator *IteratorByExpiry) Next() bool

Next moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's key and value can be retrieved by Key() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.

func (*IteratorByExpiry) Prev

func (iterator *IteratorByExpiry) Prev() bool

Prev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.

func (IteratorByExpiry) Value

func (iterator IteratorByExpiry) Value() TransactionIdWithExpiry

Value returns the current element's value. Does not modify the state of the iterator.

type IteratorById

type IteratorById struct {
	// contains filtered or unexported fields
}

func (IteratorById) HasNext

func (iter IteratorById) HasNext() bool

func (IteratorById) IsEnd

func (iter IteratorById) IsEnd() bool

func (IteratorById) Value

func (iter IteratorById) Value() (v TransactionIdWithExpiry)

type TransactionIdWithExpiry

type TransactionIdWithExpiry struct {
	TrxId  common.TransactionIdType
	Expiry common.TimePoint
}

type TransactionIdWithExpiryIndex

type TransactionIdWithExpiryIndex struct {
	// contains filtered or unexported fields
}

func NewTransactionIdWithExpiryIndex

func NewTransactionIdWithExpiryIndex() *TransactionIdWithExpiryIndex

func (*TransactionIdWithExpiryIndex) Clear

func (m *TransactionIdWithExpiryIndex) Clear()

func (*TransactionIdWithExpiryIndex) Erase

func (*TransactionIdWithExpiryIndex) GetByExpiry

func (m *TransactionIdWithExpiryIndex) GetByExpiry() *ByExpiry

func (*TransactionIdWithExpiryIndex) GetById

func (m *TransactionIdWithExpiryIndex) GetById() *ById

func (*TransactionIdWithExpiryIndex) GetFinalIndex

func (m *TransactionIdWithExpiryIndex) GetFinalIndex() interface{}

func (*TransactionIdWithExpiryIndex) GetIndex

func (m *TransactionIdWithExpiryIndex) GetIndex() interface{}

func (*TransactionIdWithExpiryIndex) GetSuperIndex

func (m *TransactionIdWithExpiryIndex) GetSuperIndex() interface{}

method for MultiIndex

func (*TransactionIdWithExpiryIndex) Insert

func (*TransactionIdWithExpiryIndex) Modify

func (*TransactionIdWithExpiryIndex) Size

type TransactionIdWithExpiryIndexBase

type TransactionIdWithExpiryIndexBase struct {
	// contains filtered or unexported fields
}

/ IndexBase

func (*TransactionIdWithExpiryIndexBase) GetFinalIndex

func (i *TransactionIdWithExpiryIndexBase) GetFinalIndex() interface{}

func (*TransactionIdWithExpiryIndexBase) GetSuperIndex

func (i *TransactionIdWithExpiryIndexBase) GetSuperIndex() interface{}

type TransactionIdWithExpiryIndexBaseNode

type TransactionIdWithExpiryIndexBaseNode struct {
	// contains filtered or unexported fields
}

type TransactionIdWithExpiryIndexNode

type TransactionIdWithExpiryIndexNode struct {
	// contains filtered or unexported fields
}

func (*TransactionIdWithExpiryIndexNode) GetFinalNode

func (n *TransactionIdWithExpiryIndexNode) GetFinalNode() interface{}

func (*TransactionIdWithExpiryIndexNode) GetSuperNode

func (n *TransactionIdWithExpiryIndexNode) GetSuperNode() interface{}

Jump to

Keyboard shortcuts

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