Re: Splay trees
- From: Jeff Garzik <jgarzik pobox com>
- To: gtk-devel-list redhat com
- Subject: Re: Splay trees
- Date: Tue, 23 Mar 1999 20:31:51 -0500 (EST)
On 21 Mar 1999, Soeren Sandmann wrote:
> To merge the implementations of all kinds of binary trees, we should
> perhaps have generic binary trees. These should not support anything
> but rotations. Perhaps it should be
>
> struct _GBinaryTreeNode
> {
> GBinaryTreeNode *left;
> GBinaryTreeNode *right;
> };
>
> The AVL trees could then define their nodes as
>
> struct _GTtreeNode
> {
> GBinaryTreeNode;
> gpointer key;
> gpointer data;
> int balance;
> };
You probably want to keep the field order the same, for binary
compatibility. Presuming that weird structure packing crap doesn't
occur, it might be better to use
struct _GTreeNode
{
gint balance; /* height (left) - height (right) */
GBinaryTreeNode bt_node;
gpointer key; /* key for this node */
gpointer value; /* value stored at this node */
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]