| 1 |
#pragma once |
| 2 |
|
| 3 |
/* Internal definitions for libcdt. |
| 4 |
** Written by Kiem-Phong Vo (5/25/96) |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <stdlib.h> |
| 8 |
|
| 9 |
#include <cdt.h> |
| 10 |
|
| 11 |
/* short-hand notations */ |
| 12 |
#define left hl._left |
| 13 |
#define hash hl._hash |
| 14 |
#define htab hh._htab |
| 15 |
#define head hh._head |
| 16 |
|
| 17 |
/* this must be disjoint from DT_METHODS */ |
| 18 |
#define DT_FLATTEN 010000 /* dictionary already flattened */ |
| 19 |
#define DT_WALK 020000 /* hash table being walked */ |
| 20 |
|
| 21 |
/* hash start size and load factor */ |
| 22 |
#define HSLOT (256) |
| 23 |
#define HRESIZE(n) ((n) << 1) |
| 24 |
#define HLOAD(s) ((s) << 1) |
| 25 |
#define HINDEX(n,h) ((h)&((n)-1)) |
| 26 |
|
| 27 |
#define UNFLATTEN(dt) ((dt->data.type & DT_FLATTEN) ? dtrestore(dt, NULL) : 0) |
| 28 |
|
| 29 |
/* tree rotation/linking functions */ |
| 30 |
#define rrotate(x,y) ((x)->left = (y)->right, (y)->right = (x)) |
| 31 |
#define lrotate(x,y) ((x)->right = (y)->left, (y)->left = (x)) |
| 32 |
#define rlink(r,x) ((r) = (r)->left = (x) ) |
| 33 |
#define llink(l,x) ((l) = (l)->right = (x) ) |
| 34 |
|
| 35 |
#define RROTATE(x,y) (rrotate(x,y), (x) = (y)) |
| 36 |
#define LROTATE(x,y) (lrotate(x,y), (x) = (y)) |