Changeset 296cc1b in mainline
- Timestamp:
- 2006-03-30T18:39:21Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ca687ad
- Parents:
- ff75d34
- Location:
- generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/adt/btree.h
rff75d34 r296cc1b 34 34 #include <adt/list.h> 35 35 36 #define BTREE_M 436 #define BTREE_M 5 37 37 #define BTREE_MAX_KEYS (BTREE_M - 1) 38 38 … … 53 53 /** 54 54 * Pointers to descendants of this node sorted according to the key array. 55 * subtree[0] points to subtree with keys lesser than or equalto key[0].56 * subtree[1] points to subtree with keys greater than key[0] and lesser than or equal tokey[1].55 * subtree[0] points to subtree with keys lesser than to key[0]. 56 * subtree[1] points to subtree with keys greater than or equal to key[0] and lesser than key[1]. 57 57 * ... 58 58 * There is room for storing a subtree pointer for the extra key. … … 81 81 82 82 extern void btree_insert(btree_t *t, __native key, void *value, btree_node_t *leaf_node); 83 extern void btree_remove(btree_t *t, __native key );83 extern void btree_remove(btree_t *t, __native key, btree_node_t *leaf_node); 84 84 extern void *btree_search(btree_t *t, __native key, btree_node_t **leaf_node); 85 85 -
generic/src/adt/btree.c
rff75d34 r296cc1b 29 29 /* 30 30 * This B-tree has the following properties: 31 * - it is a ballanced 2-3-4 tree (i.e. BTREE_M = 4)31 * - it is a ballanced 2-3-4-5 tree (i.e. BTREE_M = 5) 32 32 * - values (i.e. pointers to values) are stored only in leaves 33 33 * - leaves are linked in a list … … 61 61 #define INDEX_NODE(n) ((n)->subtree[0] != NULL) 62 62 #define LEAF_NODE(n) ((n)->subtree[0] == NULL) 63 64 #define FILL_FACTOR ((BTREE_M-1)/2) 63 65 64 66 #define MEDIAN_LOW_INDEX(n) (((n)->keys-1)/2) … … 172 174 } 173 175 174 /* TODO */ 175 void btree_remove(btree_t *t, __native key) 176 { 176 /** Remove B-tree node. 177 * 178 * @param B-tree. 179 * @param key Key to be removed from the B-tree along with its associated value. 180 * @param leaf_node If not NULL, pointer to the leaf node where the key is found. 181 */ 182 void btree_remove(btree_t *t, __native key, btree_node_t *leaf_node) 183 { 184 btree_node_t *lnode; 185 186 lnode = leaf_node; 187 if (!lnode) { 188 if (!btree_search(t, key, &lnode)) { 189 panic("B-tree %P does not contain key %d\n", t, key); 190 } 191 } 192 193 /* TODO */ 194 177 195 } 178 196
Note:
See TracChangeset
for help on using the changeset viewer.