Documentation ¶
Index ¶
- type LRU
- type MinStack
- type Node
- type Queue
- type RBTree
- type RandomizedSet
- type RingBuffer
- type SkipList
- func (s *SkipList) Del(k interface{}) (v interface{}, ok bool)
- func (s *SkipList) Get(k interface{}) (v interface{}, ok bool)
- func (s *SkipList) Len() int
- func (s *SkipList) Range(from, to interface{}, op func(v interface{}))
- func (s *SkipList) Search(k interface{}) (ok bool)
- func (s *SkipList) Set(k interface{}, v interface{})
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a FIFO queue
type RBTree ¶
type RBTree struct {
// contains filtered or unexported fields
}
RBTree is a red-black tree
func (*RBTree) Del ¶
func (t *RBTree) Del(key interface{})
Del deletes the stored value by given key
type RandomizedSet ¶
type RandomizedSet struct {
// contains filtered or unexported fields
}
RandomizedSet implements O(1) randomized set
func (*RandomizedSet) Get ¶
func (rs *RandomizedSet) Get() int
Get gets a random element from the set.
func (*RandomizedSet) Insert ¶
func (rs *RandomizedSet) Insert(val int) bool
Insert inserts a value to the set. Returns true if the set did not already contain the specified element.
func (*RandomizedSet) Remove ¶
func (rs *RandomizedSet) Remove(val int) bool
Remove removes a value from the set. Returns true if the set contained the specified element.
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer implements ring buffer queue
func NewRingBuffer ¶
func NewRingBuffer(capacity int) *RingBuffer
NewRingBuffer creates a ring buffer with given capacity
func (*RingBuffer) Get ¶
func (rb *RingBuffer) Get() (x interface{})
Get gets the first element from queue
func (*RingBuffer) IsFull ¶
func (rb *RingBuffer) IsFull() bool
IsFull checks if the ring buffer is full
func (*RingBuffer) LookAll ¶
func (rb *RingBuffer) LookAll() []interface{}
LookAll reads all elements from ring buffer this method doesn't consume all elements
func (*RingBuffer) Put ¶
func (rb *RingBuffer) Put(x interface{}) (ok bool)
Put puts x into ring buffer
type SkipList ¶
type SkipList struct { MaxLevel int // contains filtered or unexported fields }
A SkipList maintains an ordered collection of key:valkue pairs. It support insertion, lookup, and deletion operations with O(log n) time complexity Paper: Pugh, William (June 1990). "Skip lists: a probabilistic alternative to balanced trees". Communications of the ACM 33 (6): 668–676
func (*SkipList) Range ¶
func (s *SkipList) Range(from, to interface{}, op func(v interface{}))
Range interates `from` to `to` with `op`.