| 419 | */ |
| 420 | template <typename Key> |
| 421 | static Radix::Node<Key> *findAnyComplement(Radix::Node<Key> *node, Key key) |
| 422 | { |
| 423 | if (node == nullptr) |
| 424 | return nullptr; |
| 425 | if (!node->inner) |
| 426 | return ((node->key & key) == 0? node: nullptr); |
| 427 | for (unsigned i = 0; i < BRANCH_MAX; i++) |
| 428 | { |
| 429 | Radix::Node<Key> *child = node->child[i]; |
| 430 | if (child == nullptr) |
| 431 | continue; |
| 432 | if ((key & child->key) != 0) |
| 433 | continue; |
| 434 | Radix::Node<Key> *result = findAnyComplement(child, key); |
| 435 | if (result != nullptr) |
| 436 | return result; |
| 437 | } |
| 438 | |
| 439 | return nullptr; |
| 440 | } |
| 441 | |
| 442 | /* |
| 443 | * Insert a new mapping into the tree. |