golang 数据结构.
Go to file
2019-08-04 22:27:34 +08:00
compare new file: .gitignore 2019-05-08 10:42:51 +08:00
list 完成ArrayList shrink与list接口检测功能 2019-07-25 17:05:29 +08:00
map 完成ArrayList shrink与list接口检测功能 2019-07-25 17:05:29 +08:00
priority_queue vbt 代码覆盖率75%+ 修改IndexRange的bug 2019-08-04 22:24:51 +08:00
priority_queuekey vbt 代码覆盖率75%+ 修改IndexRange的bug 2019-08-04 22:24:51 +08:00
set 发现已经做了位置处理, 不需要再去改名 2019-07-22 02:02:05 +08:00
sparse_array benchmark 转移到其他仓库 2019-05-08 17:33:58 +08:00
stack 完成stack的接口标准 2019-07-25 14:30:44 +08:00
tree Merge branch 'develop' of https://github.com/474420502/focus into develop 2019-08-04 22:27:34 +08:00
utils ll完成 2019-05-20 19:12:38 +08:00
.gitignore new file: .gitignore 2019-05-08 10:42:51 +08:00
for_test.go TODO: assertImplementation, add interface InsertIf 组合等 2019-07-25 02:30:55 +08:00
go.mod 完善Remove 2019-05-17 19:54:55 +08:00
go.sum 完善Remove 2019-05-17 19:54:55 +08:00
interface.go TODO: assertImplementation, add interface InsertIf 组合等 2019-07-25 02:30:55 +08:00
LICENSE new file: .gitignore 2019-05-08 10:42:51 +08:00
README.md TODO: 验证GetNext GetPrev 是否正确 2019-07-22 02:34:57 +08:00

structure

暂时没时间整理, 后期才整理完整

PriorityQueue

package main

import (
    "log"

    "github.com/474420502/focus/compare"
    pqueuekey "github.com/474420502/focus/priority_queuekey"
)

func main() {
    pq := pqueuekey.New(compare.Int)
    pq.Push(1, 1)
    pq.Push(4, 4)
    pq.Push(5, 5)
    pq.Push(6, 6)
    pq.Push(2, 2) // pq.Values() = [6 5 4 2 1]
    log.Println(pq.Values())
    value, _ := pq.Pop() // value = 6
    log.Println(value)
    value, _ = pq.Get(1) // value = 1 pq.Values() = [5 4 2 1]
    log.Println(value)
    value, _ = pq.Get(0) // value = nil , Get equal to Seach Key
    log.Println(value)
    value, _ = pq.Index(0) // value = 5, compare.Int the order from big to small
    log.Println(value)
    values := pq.GetRange(2, 5) // values = [2 4 5]
    log.Println(values)
    values = pq.GetRange(5, 2) // values = [5 4 2]
    log.Println(values)
    values = pq.GetRange(100, 2) // values = [5 4 2]
    log.Println(values)
    values3 := pq.GetAround(5) // values3 = [<nil>, 5, 4]
    log.Println(values3)

    iter := pq.Iterator() // Next 大到小 从root节点起始
    // log.Println(iter.Value()) 直接使用会报错,
    iter.ToHead()
    log.Println(iter.Value()) // 起始最大值. true 5
    log.Println(iter.Prev(), iter.Value()) // false 5

    // Prev 大到小
    log.Println(iter.Next(), iter.Value()) // true 4
    
    
}