Documentation ¶
Index ¶
- type MaxHeap
- type MinHeap
- type Node
- type NodeScoreList
- type Sll
- func (ll *Sll) Copy() *Sll
- func (ll *Sll) Head() *Node
- func (ll *Sll) HighScores(k int) NodeScoreList
- func (ll *Sll) Len() uint
- func (ll *Sll) LowScores(k int) NodeScoreList
- func (ll *Sll) MoveToHead(n *Node)
- func (ll *Sll) MoveToTail(n *Node)
- func (ll *Sll) PushHead(v interface{}) *Node
- func (ll *Sll) PushHeadNode(n *Node)
- func (ll *Sll) PushTail(v interface{}) *Node
- func (ll *Sll) PushTailNode(n *Node)
- func (ll *Sll) Remove(n *Node)
- func (ll *Sll) RemoveHead()
- func (ll *Sll) RemoveTail()
- func (ll *Sll) Tail() *Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MaxHeap ¶
type MaxHeap []*Node
MaxHeap implements a max-heap heap.Interface.
func (*MaxHeap) Peek ¶
func (mh *MaxHeap) Peek() interface{}
Peek returns the root node from the heap.
type MinHeap ¶
type MinHeap []*Node
MinHeap implements a min-heap heap.Interface.
func (*MinHeap) Peek ¶
func (mh *MinHeap) Peek() interface{}
Peek returns the root node from the heap.
type Node ¶
type Node struct { Score uint64 Value interface{} // contains filtered or unexported fields }
Node is a scored linked list node.
type NodeScoreList ¶
type NodeScoreList []*Node
NodeScoreList is a slice of *Node sorted by ascending scores.
func (NodeScoreList) Len ¶
func (nsl NodeScoreList) Len() int
func (NodeScoreList) Less ¶
func (nsl NodeScoreList) Less(i, j int) bool
func (NodeScoreList) Swap ¶
func (nsl NodeScoreList) Swap(i, j int)
type Sll ¶
type Sll struct {
// contains filtered or unexported fields
}
Sll is a scored linked list.
func (*Sll) HighScores ¶
func (ll *Sll) HighScores(k int) NodeScoreList
HighScores takes an integer and returns the respective number of *Nodes with the higest scores sorted in ascending order.
func (*Sll) LowScores ¶
func (ll *Sll) LowScores(k int) NodeScoreList
LowScores takes an integer and returns the respective number of *Nodes with the lowest scores sorted in ascending order.
func (*Sll) MoveToHead ¶
MoveToHead takes a *Node and moves it to the front of the *Sll.
func (*Sll) MoveToTail ¶
MoveToTail takes a *Node and moves it to the back of the *Sll.
func (*Sll) PushHead ¶
PushHead creates a *Node with value v at the head of the *Sll and returns a *Node.
func (*Sll) PushHeadNode ¶
PushHeadNode pushes an existing node to the head of the *Sll.
func (*Sll) PushTail ¶
PushTail creates a *Node with value v at the tail of the *Sll and returns a *Node.
func (*Sll) PushTailNode ¶
PushTailNode pushes an existing node to the tail of the *Sll.