(final Trie o)
| 151 | } |
| 152 | |
| 153 | @Override |
| 154 | public int compareTo(final Trie o) { |
| 155 | if(o instanceof Trie) { |
| 156 | // We can be efficient here |
| 157 | Trie t1 = this; |
| 158 | Trie t2 = o; |
| 159 | while(t1.depth > t2.depth) { |
| 160 | t1 = t1.parent; |
| 161 | } |
| 162 | while(t2.depth > t1.depth) { |
| 163 | t2 = t2.parent; |
| 164 | } |
| 165 | while(t1.parent != t2.parent) { |
| 166 | t1 = t1.parent; |
| 167 | t2 = t2.parent; |
| 168 | } |
| 169 | int c = t1.component.compareTo(t2.component); |
| 170 | if(c != 0) { return c; } |
| 171 | // assert t2 == o |
| 172 | int tDepth = t2.depth; |
| 173 | if(depth < tDepth) { |
| 174 | return -1; |
| 175 | } else if(depth > tDepth) { |
| 176 | return 1; |
| 177 | } else { |
| 178 | return 0; |
| 179 | } |
| 180 | } else { |
| 181 | throw new IllegalArgumentException("Attempting to compare Trie with some other Path.ID"); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | @Override |
| 186 | public int hashCode() { |
no outgoing calls