Changeset 1226 for to-imperative/trunk/runtime/rf_table.cc
- Timestamp:
- Aug 15, 2003, 10:11:57 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/trunk/runtime/rf_table.cc
r1221 r1226 11 11 size_t Table::count = 0; 12 12 13 // 14 // inserting of element newNode in this-Table 13 // 14 // inserting of element newNode in this-Table 15 15 void Table::insert_node (TableNode* _node) 16 { 16 { 17 17 TableNode* x; 18 18 TableNode* y; 19 19 int flag; 20 20 y = TableNode::nil; 21 x = root; 21 x = root; 22 22 while (x != TableNode::nil) { 23 23 y=x; 24 if ((_node->hash_key) == (x->hash_key)) { 24 if ((_node->hash_key) == (x->hash_key)) { 25 25 flag = Expr::compare(_node->key, x->key); 26 if (!flag) // case 0 : ==26 if (!flag) { // case 0 : == 27 27 return; 28 if (flag < 0) {// case < 0 : <28 } else if (flag < 0) { // case < 0 : < 29 29 x = x->left; 30 continue;31 30 } else { 32 31 x = x->right; 33 continue; 34 } 32 } 33 } else if ((_node->hash_key) < (x->hash_key)) { 34 x = x->left; 35 } else { 36 x = x->right; 35 37 } 36 if ((_node->hash_key) < (x->hash_key))37 x = x->left;38 else39 x = x->right;40 38 } 41 39 _node->p = y; 42 if (y == TableNode::nil) 43 root = _node; 44 else 45 if ((_node->hash_key) == (x->hash_key)) { 46 flag = Expr::compare(_node->key, x->key); 40 if (y == TableNode::nil) { 41 root = _node; 42 } else { 43 // 44 // FIXME: Here we already chosen valid direction, so probably we 45 // should introduce a flag indicating that direction to avoid possible 46 // duplicated compare(). [pooh 2003-08-15] 47 if ((_node->hash_key) == (y->hash_key)) { 48 flag = Expr::compare(_node->key, y->key); 47 49 if (flag < 0) { 48 50 y->left = _node; 49 return;50 51 } else { 51 52 y->right = _node; 52 return;53 }54 }55 if ((_node->hash_key) < (y->hash_key))56 y->left = _node;57 else58 y->right = _node;53 } 54 } else if ((_node->hash_key) < (y->hash_key)) { 55 y->left = _node; 56 } else { 57 y->right = _node; 58 } 59 } 59 60 } 60 61
Note: See TracChangeset
for help on using the changeset viewer.