MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / compareTo

Method compareTo

src/main/java/wycc/util/Trie.java:153–183  ·  view source on GitHub ↗
(final Trie o)

Source from the content-addressed store, hash-verified

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() {

Callers 7

lessThanMethod · 0.45
lessThanOrEqualMethod · 0.45
compareMethod · 0.45
compareMethod · 0.45
compareMethod · 0.45
compareMethod · 0.45
binarySearchMethod · 0.45

Calls

no outgoing calls

Tested by 1

compareMethod · 0.36