Documentation ¶
Overview ¶
Package sortutil contains common sorting definitions and utilities for sorting data.
Index ¶
- func Int64s(a []int64)
- func InterfaceStrings(a []interface{})
- func UInt64s(a []uint64)
- type AbstractSlice
- type Int64Slice
- type IntHeap
- type PriorityQueue
- func (pq *PriorityQueue) Clear()
- func (pq *PriorityQueue) CurrentPriority() int
- func (pq *PriorityQueue) Peek() interface{}
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Push(value interface{}, priority int)
- func (pq *PriorityQueue) Size() int
- func (pq *PriorityQueue) SizeCurrentPriority() int
- func (pq *PriorityQueue) String() string
- type UInt64Slice
- type VectorClock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InterfaceStrings ¶
func InterfaceStrings(a []interface{})
InterfaceStrings sorts a slice of interface{} in increasing order by their string values.
Types ¶
type AbstractSlice ¶
type AbstractSlice []interface{}
AbstractSlice is a special type implementing the sort interface for interface{} (Sorting is by string value)
func (AbstractSlice) Len ¶
func (p AbstractSlice) Len() int
func (AbstractSlice) Less ¶
func (p AbstractSlice) Less(i, j int) bool
func (AbstractSlice) Swap ¶
func (p AbstractSlice) Swap(i, j int)
type Int64Slice ¶
type Int64Slice []int64
Int64Slice is a special type implementing the sort interface for int64
func (Int64Slice) Len ¶
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶
func (p Int64Slice) Swap(i, j int)
type IntHeap ¶
type IntHeap []int
IntHeap is a classic heap with int values.
func (*IntHeap) RemoveFirst ¶
RemoveFirst removes the first occurrences of item r from the IntHeap.
type PriorityQueue ¶
type PriorityQueue struct { MinPriority func() int // Function returning the minimum priority // contains filtered or unexported fields }
PriorityQueue is like a regular queue where each element has a priority. Items with higher priority are served first. Items with the same priority are returned in the order they were added. Priority 0 is the highest priority with the priority decreasing as the priority number increases.
It is possible to set a minimum priority function on the PriorityQueue object. The function returns the current minimum priority level which should be returned by the queue. If the current available priority is lower than this then len() will return 0 and pop will return nil. If the function returns a negative value then the value is ignored.
func NewPriorityQueue ¶
func NewPriorityQueue() *PriorityQueue
NewPriorityQueue creates a new priority queue.
func (*PriorityQueue) Clear ¶
func (pq *PriorityQueue) Clear()
Clear clears the current queue contents.
func (*PriorityQueue) CurrentPriority ¶
func (pq *PriorityQueue) CurrentPriority() int
CurrentPriority returns the priority of the next item.
func (*PriorityQueue) Peek ¶
func (pq *PriorityQueue) Peek() interface{}
Peek returns the next item of the queue but does not remove it.
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
Pop remove the next element from the queue and returns it.
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(value interface{}, priority int)
Push adds a new element to the queue.
func (*PriorityQueue) Size ¶
func (pq *PriorityQueue) Size() int
Size returns the current queue size.
func (*PriorityQueue) SizeCurrentPriority ¶
func (pq *PriorityQueue) SizeCurrentPriority() int
SizeCurrentPriority returns the queue size of all elements of the highest priority.
func (*PriorityQueue) String ¶
func (pq *PriorityQueue) String() string
String returns a string representation of the queue.
type UInt64Slice ¶
type UInt64Slice []uint64
UInt64Slice is a special type implementing the sort interface for uint64
func (UInt64Slice) Len ¶
func (p UInt64Slice) Len() int
func (UInt64Slice) Less ¶
func (p UInt64Slice) Less(i, j int) bool
func (UInt64Slice) Swap ¶
func (p UInt64Slice) Swap(i, j int)
type VectorClock ¶
type VectorClock struct {
// contains filtered or unexported fields
}
VectorClock implements a vector clock object. The clock can record actions of actors. Each action produces a new version which can be queried.
func CloneVectorClock ¶
func CloneVectorClock(vc *VectorClock) *VectorClock
CloneVectorClock clones an existing vector clock.
func NewDescendant ¶
func NewDescendant(otherVCs ...*VectorClock) *VectorClock
NewDescendant creates a vector clock which is a descendant of all given vector clocks.
func NewVectorClock ¶
func NewVectorClock() *VectorClock
NewVectorClock creates a new vector clock datastructure.
func (*VectorClock) Act ¶
func (vc *VectorClock) Act(actor string)
Act records an action of an actor.
func (*VectorClock) IsConflicting ¶
func (vc *VectorClock) IsConflicting(otherVC *VectorClock) bool
IsConflicting determines if another vector clock is conflicting with this vector clock.
func (*VectorClock) IsDescendent ¶
func (vc *VectorClock) IsDescendent(otherVC *VectorClock) bool
IsDescendent determines if another vector clock is a descendent of this vector clock.
func (*VectorClock) String ¶
func (vc *VectorClock) String() string
String returns a string representation of this vector clock.
func (*VectorClock) Version ¶
func (vc *VectorClock) Version(actor string) uint64
Version returns the current version for a given actor.