@Override @Nullable public V get(K key) { int index = SortedLists.binarySearch( ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key), KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER); if (index == -1) { return null; } else { Range<K> range = ranges.get(index); return range.contains(key) ? values.get(index) : null; } }
@Override @Nullable public Map.Entry<Range<K>, V> getEntry(K key) { int index = SortedLists.binarySearch( ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key), KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER); if (index == -1) { return null; } else { Range<K> range = ranges.get(index); return range.contains(key) ? Maps.immutableEntry(range, values.get(index)) : null; } }
@Override @NullableDecl public V get(K key) { int index = SortedLists.binarySearch( ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key), KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER); if (index == -1) { return null; } else { Range<K> range = ranges.get(index); return range.contains(key) ? values.get(index) : null; } }
@Override @NullableDecl public Entry<Range<K>, V> getEntry(K key) { int index = SortedLists.binarySearch( ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key), KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER); if (index == -1) { return null; } else { Range<K> range = ranges.get(index); return range.contains(key) ? Maps.immutableEntry(range, values.get(index)) : null; } }
public void testWithoutDups() { for (KeyPresentBehavior presentBehavior : KeyPresentBehavior.values()) { for (KeyAbsentBehavior absentBehavior : KeyAbsentBehavior.values()) { for (int key = 0; key <= 10; key++) { assertModelAgrees(LIST_WITHOUT_DUPS, key, SortedLists.binarySearch(LIST_WITHOUT_DUPS, key, presentBehavior, absentBehavior), presentBehavior, absentBehavior); } } } }
public void testWithDups() { for (KeyPresentBehavior presentBehavior : KeyPresentBehavior.values()) { for (KeyAbsentBehavior absentBehavior : KeyAbsentBehavior.values()) { for (int key = 0; key <= 10; key++) { assertModelAgrees(LIST_WITH_DUPS, key, SortedLists.binarySearch(LIST_WITH_DUPS, key, presentBehavior, absentBehavior), presentBehavior, absentBehavior); } } } }
@Override @Nullable public V get(K key) { int index = SortedLists.binarySearch(ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key), KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER); if (index == -1) { return null; } else { Range<K> range = ranges.get(index); return range.contains(key) ? values.get(index) : null; } }
@Override @Nullable public Map.Entry<Range<K>, V> getEntry(K key) { int index = SortedLists.binarySearch(ranges, Range.<K>lowerBoundFn(), Cut.belowValue(key), KeyPresentBehavior.ANY_PRESENT, KeyAbsentBehavior.NEXT_LOWER); if (index == -1) { return null; } else { Range<K> range = ranges.get(index); return range.contains(key) ? Maps.immutableEntry(range, values.get(index)) : null; } }
public void testWithoutDups() { for (KeyPresentBehavior presentBehavior : KeyPresentBehavior.values()) { for (KeyAbsentBehavior absentBehavior : KeyAbsentBehavior.values()) { for (int key = 0; key <= 10; key++) { assertModelAgrees( LIST_WITHOUT_DUPS, key, SortedLists.binarySearch(LIST_WITHOUT_DUPS, key, presentBehavior, absentBehavior), presentBehavior, absentBehavior); } } } }
public void testWithDups() { for (KeyPresentBehavior presentBehavior : KeyPresentBehavior.values()) { for (KeyAbsentBehavior absentBehavior : KeyAbsentBehavior.values()) { for (int key = 0; key <= 10; key++) { assertModelAgrees( LIST_WITH_DUPS, key, SortedLists.binarySearch(LIST_WITH_DUPS, key, presentBehavior, absentBehavior), presentBehavior, absentBehavior); } } } }