基于仓颉语言的优先队列实现。
PriorityQueue implementation based on cangjie.
# In the `dependencies` section of `cjpm.toml`
priorityqueue4cj = { git = "https://github.com/gtn1024/priorityqueue4cj.git" }
Comparator:
let pq = PriorityQueue<Int64>.create<Int64>({ a, b =>
if (a < b) {
Ordering.GT
} else if (a > b) {
Ordering.LT
} else {
Ordering.EQ
}
})
pq.push(1)
pq.push(2)
pq.push(3)
while (!pq.empty()) {
println(pq.pop()) // 1, 2, 3
}
欢迎加入 仓颉交流群(非官方):985038695