Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BSTInterface ¶
type BSTInterface interface { // Adds new elem to the tree, will not check if same val already exists Insert(interface{}) *Node // Returns the first node that matches Search(interface{}) *Node // In-order traversal of tree copied to slice ToSlice() []interface{} // In-order traversal of tree, calling the func for each element visited Traverse(func(interface{})) // Returns the largest value node that is smaller than or equal to the given value. Floor(interface{}) *Node // Returns the smallest value node that is larger than or equal to the given value. Ceiling(interface{}) *Node }
Binary Search Tree implementation https://en.wikipedia.org/wiki/Binary_search_tree Element comparison is based on OrderFunc provided to NewBST method
type BinaryIndexTree ¶ added in v1.0.5
type BinaryIndexTree struct {
// contains filtered or unexported fields
}
func (BinaryIndexTree) Query ¶ added in v1.0.5
func (bit BinaryIndexTree) Query(x int) int
func (BinaryIndexTree) Update ¶ added in v1.0.5
func (bit BinaryIndexTree) Update(x, val int)
type BinaryIndexTreeInterface ¶ added in v1.0.5
type BinaryIndexTreeInterface interface { //add "val" at index "x" Update(x, val int) //returns the sum of first x elements Query(x int) int }
func NewBinaryIndexTree ¶ added in v1.0.5
func NewBinaryIndexTree(size int) BinaryIndexTreeInterface
type SegmentTree ¶ added in v1.0.5
type SegmentTree struct {
// contains filtered or unexported fields
}
func (SegmentTree) QueryRange ¶ added in v1.0.5
func (st SegmentTree) QueryRange(start, end int) interface{}
func (SegmentTree) UpdateRange ¶ added in v1.0.5
func (st SegmentTree) UpdateRange(start, end int, updateFunc lib.UpdateFunc)
type SegmentTreeInterface ¶ added in v1.0.5
type SegmentTreeInterface interface { UpdateRange(start, end int, updateFunc lib.UpdateFunc) QueryRange(start, end int) interface{} }
func NewSegmentTree ¶ added in v1.0.5
func NewSegmentTree(qFunc lib.QueryEvalFunc, dFunc lib.DisjointValFunc) SegmentTreeInterface
Click to show internal directories.
Click to hide internal directories.