Documentation ¶
Index ¶
- Variables
- type CompareFunc
- type Item
- type PriorityItem
- type PriorityQueue
- func (pq *PriorityQueue) Close() error
- func (pq *PriorityQueue) Dequeue() (*PriorityItem, error)
- func (pq *PriorityQueue) Drop() error
- func (pq *PriorityQueue) EnqueueObject(value interface{}, priority uint8) (*PriorityItem, error)
- func (pq *PriorityQueue) EnqueueString(value string, priority uint8) (*PriorityItem, error)
- func (pq *PriorityQueue) EnqueueWithPriority(value []byte, priority uint8) (*PriorityItem, error)
- func (pq *PriorityQueue) Length() uint64
- func (pq *PriorityQueue) Peek() (*PriorityItem, error)
- type Queue
- func (q *Queue) Close() error
- func (q *Queue) Dequeue() (*Item, error)
- func (q *Queue) Drop() error
- func (q *Queue) Enqueue(value []byte) (*Item, error)
- func (q *Queue) EnqueueObject(value interface{}) (*Item, error)
- func (q *Queue) EnqueueString(value string) (*Item, error)
- func (q *Queue) Length() uint64
- func (q *Queue) Peek() (*Item, error)
- type SortedList
- type Stack
- func (s *Stack) Close() error
- func (s *Stack) Drop() error
- func (s *Stack) Length() uint64
- func (s *Stack) Peek() (*Item, error)
- func (s *Stack) PeekByID(id uint64) (*Item, error)
- func (s *Stack) PeekByOffset(offset uint64) (*Item, error)
- func (s *Stack) Pop() (*Item, error)
- func (s *Stack) Push(value []byte) (*Item, error)
- func (s *Stack) PushObject(value interface{}) (*Item, error)
- func (s *Stack) PushString(value string) (*Item, error)
- func (s *Stack) Update(id uint64, newValue []byte) (*Item, error)
- func (s *Stack) UpdateObject(id uint64, newValue interface{}) (*Item, error)
- func (s *Stack) UpdateString(id uint64, newValue string) (*Item, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CompareFunc ¶
type CompareFunc func(interface{}, interface{}) int
type PriorityItem ¶
PriorityItem extends Item with a priority field
type PriorityQueue ¶
PriorityQueue implements a priority queue using leveldb
func OpenPriorityQueue ¶
func OpenPriorityQueue(dataDir string) (*PriorityQueue, error)
OpenPriorityQueue creates or opens a priority queue
func (*PriorityQueue) Close ¶
func (pq *PriorityQueue) Close() error
Close closes the priority queue database
func (*PriorityQueue) Dequeue ¶
func (pq *PriorityQueue) Dequeue() (*PriorityItem, error)
Dequeue removes and returns the highest priority item
func (*PriorityQueue) Drop ¶
func (pq *PriorityQueue) Drop() error
Drop closes and deletes the priority queue database
func (*PriorityQueue) EnqueueObject ¶
func (pq *PriorityQueue) EnqueueObject(value interface{}, priority uint8) (*PriorityItem, error)
func (*PriorityQueue) EnqueueString ¶
func (pq *PriorityQueue) EnqueueString(value string, priority uint8) (*PriorityItem, error)
func (*PriorityQueue) EnqueueWithPriority ¶
func (pq *PriorityQueue) EnqueueWithPriority(value []byte, priority uint8) (*PriorityItem, error)
EnqueueWithPriority adds an item to the queue with specified priority
func (*PriorityQueue) Length ¶
func (pq *PriorityQueue) Length() uint64
Length returns the number of items in the queue
func (*PriorityQueue) Peek ¶
func (pq *PriorityQueue) Peek() (*PriorityItem, error)
Peek returns the highest priority item without removing it
type SortedList ¶
type SortedList struct {
// contains filtered or unexported fields
}
func NewSortedList ¶
func NewSortedList(compare CompareFunc) *SortedList
func (*SortedList) Back ¶
func (l *SortedList) Back() *list.Element
func (*SortedList) Clear ¶
func (l *SortedList) Clear()
func (*SortedList) Front ¶
func (l *SortedList) Front() *list.Element
func (*SortedList) Insert ¶
func (l *SortedList) Insert(item interface{})
Only Search from front to end, optimized for from end to front
func (*SortedList) Len ¶
func (l *SortedList) Len() int64
func (*SortedList) Remove ¶
func (l *SortedList) Remove(e *list.Element) interface{}
type Stack ¶
Stack is a standard LIFO (last in, first out) stack.
func OpenStack ¶
OpenStack opens a stack if one exists at the given directory. If one does not already exist, a new stack is created.
func (*Stack) PeekByOffset ¶
PeekByOffset returns the item located at the given offset, starting from the head of the stack, without removing it.
func (*Stack) PushObject ¶
PushObject is a helper function for Push that accepts any value type, which is then encoded into a byte slice using encoding/gob.
func (*Stack) PushString ¶
PushString is a helper function for Push that accepts a value as a string rather than a byte slice.
func (*Stack) UpdateObject ¶
UpdateObject is a helper function for Update that accepts any value type, which is then encoded into a byte slice using encoding/gob.