golang 数据结构.
Go to file
2019-07-20 04:03:21 +08:00
compare new file: .gitignore 2019-05-08 10:42:51 +08:00
heap benchmark 转移到其他仓库 2019-05-08 17:33:58 +08:00
lastack 修复单元测试的长度判断不正确 2019-05-08 17:57:10 +08:00
list linked_hashmap 完成, 90%+覆盖率 2019-07-19 19:05:35 +08:00
map linked_hashmap 完成, 90%+覆盖率 2019-07-19 19:05:35 +08:00
priority_queue 测试 2019-07-18 14:32:37 +08:00
priority_queuekey go Rename 不保存 修复: SeNode to SetNode 2019-07-18 14:37:50 +08:00
set Iterator 添加GetNode函数, 修改SeNode缺字母SetNode 2019-07-18 14:25:15 +08:00
sparse_array benchmark 转移到其他仓库 2019-05-08 17:33:58 +08:00
stack 完成stack的单元测试 2019-07-20 03:55:45 +08:00
tree Iterator 添加GetNode函数, 修改SeNode缺字母SetNode 2019-07-18 14:25:15 +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 new file: .gitignore 2019-05-08 10:42:51 +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 new file: .gitignore 2019-05-08 10:42:51 +08:00
LICENSE new file: .gitignore 2019-05-08 10:42:51 +08:00
README.md readme change 2019-07-18 15:00:20 +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 小到大
    // log.Println(iter.Value()) 直接使用会报错,
    iter.Next() // Next 从小到大
    log.Println(iter.Value()) // 起始最大值. true 5

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