### Question:
SortedRangeList implements Iterable<Range> { public int getRangeIndex(int value) { Range key = new Range(value, value); SortedSet<Range> head = set.headSet(key); int index = head.size() - 1; if (!head.isEmpty()) { Range last = head.last(); if (last.max >= value) { return index; } } index++; SortedSet<Range> tail = set.tailSet(key); if (!tail.isEmpty()) { Range range = tail.first(); if (range.min == value) { return index; } } return -index - 1; } SortedRangeList();  SortedRangeList(SortedRangeList list); void addRange(int min, int max); Iterator<Range> getRanges(); Iterator<Range> getRanges(boolean forward); int getMin(); int getMax(); int getNumRanges(); void removeRange(int min, int max); boolean contains(int value); boolean contains(int min, int max); int getRangeIndex(int value); Range getRange(int index); long getNumValues(); boolean intersects(int min, int max); boolean isEmpty(); void remove(SortedRangeList other); SortedRangeList intersect(SortedRangeList other); @Override String toString(); @Override Iterator<Range> iterator();  }### Answer:
@Test public void testGetRangeIndex() { list.addRange(-231, -111); list.addRange(2,4); list.addRange(6,8); list.addRange(12,15); assertEquals(-1, list.getRangeIndex(Integer.MIN_VALUE)); assertEquals(-1, list.getRangeIndex(-232)); assertEquals(0, list.getRangeIndex(-231)); assertEquals(0, list.getRangeIndex(-111)); assertEquals(-2, list.getRangeIndex(-110)); assertEquals(-2, list.getRangeIndex(-1)); assertEquals(-2, list.getRangeIndex(0)); assertEquals(-2, list.getRangeIndex(1)); assertEquals(1, list.getRangeIndex(2)); assertEquals(1, list.getRangeIndex(3)); assertEquals(1, list.getRangeIndex(4)); assertEquals(-3, list.getRangeIndex(5)); assertEquals(2, list.getRangeIndex(6)); assertEquals(2, list.getRangeIndex(7)); assertEquals(2, list.getRangeIndex(8)); assertEquals(-4, list.getRangeIndex(9)); assertEquals(-4, list.getRangeIndex(10)); assertEquals(-4, list.getRangeIndex(11)); assertEquals(3, list.getRangeIndex(12)); assertEquals(3, list.getRangeIndex(13)); assertEquals(3, list.getRangeIndex(14)); assertEquals(3, list.getRangeIndex(15)); assertEquals(-5, list.getRangeIndex(16)); assertEquals(-5, list.getRangeIndex(17)); assertEquals(-5, list.getRangeIndex(Integer.MAX_VALUE)); }