| 89 | } |
| 90 | |
| 91 | void Node::setChild(NodeID nid, int alt) |
| 92 | { |
| 93 | |
| 94 | auto kids = childrenCount(); |
| 95 | |
| 96 | if (kids <= 0) |
| 97 | { |
| 98 | throw no_child(); |
| 99 | } |
| 100 | else if (kids <= 2) |
| 101 | { |
| 102 | if (alt == 0) |
| 103 | { |
| 104 | m_childrenOrFirstChild = |
| 105 | reinterpret_cast<void *>(static_cast<int>(nid) << 2); |
| 106 | setNumberOfChildren(kids); |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | if (alt != 1) |
| 111 | { |
| 112 | throw std::exception(); |
| 113 | } |
| 114 | m_noOfChildren = -static_cast<int>(nid); |
| 115 | } |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | getPtr()[alt] = nid; |
| 120 | } |
| 121 | |
| 122 | auto kids2 = childrenCount(); |
| 123 | |
| 124 | if (kids != kids2) |
| 125 | throw; |
| 126 | } |
| 127 | |
| 128 | NodeID Node::getChild(int alt) const |
| 129 | { |
no test coverage detected