gb_trees

来源:互联网 发布:上膛雾化器做丝数据 编辑:程序博客网 时间:2024/05/26 09:55
gb_trees(General Balanced Trees)


DESCRIPTION:

An efficient implementation of Prof. Arne Andersson's General Balanced Trees. These have no storage overhead compared to unbalanced binary trees, and their performance is in general better than AVL trees.

This module considers two keys as different if and only if they do not compare equal (==).

通用二叉树,通常被用作有序字典.与普通未平衡二叉树相比没有额外的储存开销,这里所说的额外的存储开销是指是否使用额外的metadata记录节点相关的信息,dict和array的实现就使用了这样的描述信息,换句话说gb_trees是自描述的.性能优于AVL trees.和proplists,orddict相比它能够支持更大的数据量. 


平衡二叉树(AVL树) ,左右子树的深度(一棵树中最大的结点度数)只差绝对值不超过1.这个插值称为平衡因子(balance factor),查找,插入和删除在平均和最坏情况下都是O(logn).节点的插入和删除平衡树失衡会触发重新平衡.重新平衡通过四种旋转实现:LL LR RR RL.gb_trees由于节点删除操作并不会增加树的高度,所以节点删除之后并没有进行再平衡.
 gb_treess数据项比较使用的是相等==操作符.

Data structure:

      - {Size, Tree}  - {Key, Value, Smaller, Bigger},   - nil.


具体的详细操作见:坚强的博客
http://www.cnblogs.com/me-sa/archive/2012/06/23/erlang-gb_trees.html




原创粉丝点击