如何在 Workiva/go-datastructures/ 中使用 btree/plus

How to use btree/plus in Workiva/go-datastructures/

我一直需要二叉树的实现。我在这里找到了一个。

但我不太确定如何使用它。这个 repo 中的其他数据结构非常简单。只需调用他的包和 运行 方法。但是这个btree有点让人迷惑

我只想要一个简单的示例,说明如何创建、插入和检索由此包创建的树。

  1. 创建btree/plus
  2. 插入密钥
  3. 检索范围

godoc for it says "As of this writing, the tree is not quite finished", and it doesn't seem to expose a public interface for creating a tree at all. Functions like newBtree and get exist in the source但是是私有的,从名字就可以看出。

An old benchmark of btree packages also serves as a set of pointers to various ordered collection packages. google/btree is from Google. cznic/b 是一个 B+ 树,正如 btree/plus was/is 计划的那样,并且还提供了进行代码生成而不是使用 interfaces 的选项。