VCS: area map: contains(); [a/c, a/c/d] to insert a/c/e case -> check all occurencies before found insert place

This commit is contained in:
irengrig
2010-06-23 13:49:31 +04:00
parent 05ba3e62e5
commit eeca4c7c2e
@@ -67,6 +67,10 @@ public class AreaMap<Key extends Comparable<Key>, Val> {
}
}
public boolean contains(final Key key) {
return myKeys.contains(key);
}
public void getSimiliar(final Key key, final PairProcessor<Key, Val> consumer) {
final int idx = Collections.binarySearch(myKeys, key);
if (idx < 0) {
@@ -76,7 +80,7 @@ public class AreaMap<Key extends Comparable<Key>, Val> {
if (itemBeforeIdx >= 0) {
for (int i = itemBeforeIdx; i >= 0; -- i) {
final Key candidate = myKeys.get(i);
if (! myKeysResemblance.process(candidate, key)) break;
if (! myKeysResemblance.process(candidate, key)) continue;
if (consumer.process(candidate, myMap.get(candidate))) break; // if need only a part of keys
}
}