@CollectionSize.Require(SEVERAL) public void testLower() { resetWithHole(); assertEquals(null, navigableMap.lowerEntry(a.getKey())); assertEquals(null, navigableMap.lowerKey(a.getKey())); assertEquals(a, navigableMap.lowerEntry(b.getKey())); assertEquals(a.getKey(), navigableMap.lowerKey(b.getKey())); assertEquals(a, navigableMap.lowerEntry(c.getKey())); assertEquals(a.getKey(), navigableMap.lowerKey(c.getKey())); }
private void add( NavigableMap<Interval, TimelineEntry> timeline, Interval interval, TimelineEntry entry) { TimelineEntry existsInTimeline = timeline.get(interval); if (existsInTimeline != null) { int compare = versionComparator.compare(entry.getVersion(), existsInTimeline.getVersion()); if (compare > 0) { addIntervalToTimeline(interval, entry, timeline); } return; } Interval lowerKey = timeline.lowerKey(interval); if (lowerKey != null) { if (addAtKey(timeline, lowerKey, entry)) { return; } } Interval higherKey = timeline.higherKey(interval); if (higherKey != null) { if (addAtKey(timeline, higherKey, entry)) { return; } } addIntervalToTimeline(interval, entry, timeline); }
@CollectionSize.Require(ZERO) public void testEmptyMapNearby() { assertNull(navigableMap.lowerEntry(samples.e0.getKey())); assertNull(navigableMap.lowerKey(samples.e0.getKey())); assertNull(navigableMap.floorEntry(samples.e0.getKey())); assertNull(navigableMap.floorKey(samples.e0.getKey())); assertNull(navigableMap.ceilingEntry(samples.e0.getKey())); assertNull(navigableMap.ceilingKey(samples.e0.getKey())); assertNull(navigableMap.higherEntry(samples.e0.getKey())); assertNull(navigableMap.higherKey(samples.e0.getKey())); }
@CollectionSize.Require(ONE) public void testSingletonMapNearby() { assertNull(navigableMap.lowerEntry(samples.e0.getKey())); assertNull(navigableMap.lowerKey(samples.e0.getKey())); assertEquals(a, navigableMap.floorEntry(samples.e0.getKey())); assertEquals(a.getKey(), navigableMap.floorKey(samples.e0.getKey())); assertEquals(a, navigableMap.ceilingEntry(samples.e0.getKey())); assertEquals(a.getKey(), navigableMap.ceilingKey(samples.e0.getKey())); assertNull(navigableMap.higherEntry(samples.e0.getKey())); assertNull(navigableMap.higherKey(samples.e0.getKey())); }