Staging
v0.5.1
https://github.com/python/cpython
Revision f156b0c2b34da88913923711b8ceb8160d29d171 authored by Georg Brandl on 16 July 2008, 23:19:01 UTC, committed by Georg Brandl on 16 July 2008, 23:19:01 UTC
........
  r65046 | georg.brandl | 2008-07-17 01:18:51 +0200 (Thu, 17 Jul 2008) | 2 lines

  Byte items *can* be chars in 2.6.
........
1 parent 94f3e9a
Raw File
Tip revision: f156b0c2b34da88913923711b8ceb8160d29d171 authored by Georg Brandl on 16 July 2008, 23:19:01 UTC
Blocked revisions 65046 via svnmerge
Tip revision: f156b0c
rotatingtree.h
/* "Rotating trees" (Armin Rigo)
 *
 * Google "splay trees" for the general idea.
 *
 * It's a dict-like data structure that works best when accesses are not
 * random, but follow a strong pattern.  The one implemented here is for
 * access patterns where the same small set of keys is looked up over
 * and over again, and this set of keys evolves slowly over time.
 */

#include <stdlib.h>

#define EMPTY_ROTATING_TREE       ((rotating_node_t *)NULL)

typedef struct rotating_node_s rotating_node_t;
typedef int (*rotating_tree_enum_fn) (rotating_node_t *node, void *arg);

struct rotating_node_s {
	void *key;
	rotating_node_t *left;
	rotating_node_t *right;
};

void RotatingTree_Add(rotating_node_t **root, rotating_node_t *node);
rotating_node_t* RotatingTree_Get(rotating_node_t **root, void *key);
int RotatingTree_Enum(rotating_node_t *root, rotating_tree_enum_fn enumfn,
		      void *arg);
back to top