@Test public void testPutNull() { for (IntervalMap set : getAllInstances()) { boolean thrown = false; try { set.put(new Interval(1.0, 2.0), null); } catch (NullPointerException e) { thrown = true; } if (!thrown) { Assert.fail("Didn't throw an exception for " + set.getClass()); } } }
@Override public boolean put(Interval interval, T value) { if (value == null) { throw new NullPointerException(); } Object values = getValuesArray(); int valuesLength = Array.getLength(values); final int index = putInner(interval.getLow(), interval.getHigh()); if (index < 0) { int insertIndex = -index - 1; if (size - 1 < valuesLength) { if (insertIndex < size - 1) { System.arraycopy(values, insertIndex, values, insertIndex + 1, size - insertIndex - 1); } Array.set(values, insertIndex, value); } else { Object newArray = Array.newInstance(values.getClass().getComponentType(), valuesLength + 1); System.arraycopy(values, 0, newArray, 0, insertIndex); System.arraycopy(values, insertIndex, newArray, insertIndex + 1, valuesLength - insertIndex); Array.set(newArray, insertIndex, value); setValuesArray(newArray); } return true; } else { Array.set(values, index, value); } return false; }
IntervalMap implements TimeMap<Interval, T> { @Override public boolean put(Interval interval, T value) { if (value == null) { throw new NullPointerException(); } Object values = getValuesArray(); int valuesLength = Array.getLength(values); final int index = putInner(interval.getLow(), interval.getHigh()); if (index < 0) { int insertIndex = -index - 1; if (size - 1 < valuesLength) { if (insertIndex < size - 1) { System.arraycopy(values, insertIndex, values, insertIndex + 1, size - insertIndex - 1); } Array.set(values, insertIndex, value); } else { Object newArray = Array.newInstance(values.getClass().getComponentType(), valuesLength + 1); System.arraycopy(values, 0, newArray, 0, insertIndex); System.arraycopy(values, insertIndex, newArray, insertIndex + 1, valuesLength - insertIndex); Array.set(newArray, insertIndex, value); setValuesArray(newArray); } return true; } else { Array.set(values, index, value); } return false; } }
IntervalMap implements TimeMap<Interval, T> { @Override public boolean put(Interval interval, T value) { if (value == null) { throw new NullPointerException(); } Object values = getValuesArray(); int valuesLength = Array.getLength(values); final int index = putInner(interval.getLow(), interval.getHigh()); if (index < 0) { int insertIndex = -index - 1; if (size - 1 < valuesLength) { if (insertIndex < size - 1) { System.arraycopy(values, insertIndex, values, insertIndex + 1, size - insertIndex - 1); } Array.set(values, insertIndex, value); } else { Object newArray = Array.newInstance(values.getClass().getComponentType(), valuesLength + 1); System.arraycopy(values, 0, newArray, 0, insertIndex); System.arraycopy(values, insertIndex, newArray, insertIndex + 1, valuesLength - insertIndex); Array.set(newArray, insertIndex, value); setValuesArray(newArray); } return true; } else { Array.set(values, index, value); } return false; } IntervalMap();  IntervalMap(int capacity); protected  IntervalMap(double[] keys); }
IntervalMap implements TimeMap<Interval, T> { @Override public boolean put(Interval interval, T value) { if (value == null) { throw new NullPointerException(); } Object values = getValuesArray(); int valuesLength = Array.getLength(values); final int index = putInner(interval.getLow(), interval.getHigh()); if (index < 0) { int insertIndex = -index - 1; if (size - 1 < valuesLength) { if (insertIndex < size - 1) { System.arraycopy(values, insertIndex, values, insertIndex + 1, size - insertIndex - 1); } Array.set(values, insertIndex, value); } else { Object newArray = Array.newInstance(values.getClass().getComponentType(), valuesLength + 1); System.arraycopy(values, 0, newArray, 0, insertIndex); System.arraycopy(values, insertIndex, newArray, insertIndex + 1, valuesLength - insertIndex); Array.set(newArray, insertIndex, value); setValuesArray(newArray); } return true; } else { Array.set(values, index, value); } return false; } IntervalMap();  IntervalMap(int capacity); protected  IntervalMap(double[] keys); @Override boolean put(Interval interval, T value); @Override boolean remove(Interval interval); @Override Object get(Interval interval, Estimator estimator); @Override T get(Interval interval, T defaultValue); @Override T[] toValuesArray(); @Override int size(); @Override boolean isEmpty(); boolean contains(double timestamp); @Override boolean contains(Interval interval); @Override Interval[] toKeysArray(); double[] getIntervals(); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(TimeFormat timeFormat, DateTimeZone timeZone); @Override String toString(TimeFormat timeFormat); @Override String toString(); }
IntervalMap implements TimeMap<Interval, T> { @Override public boolean put(Interval interval, T value) { if (value == null) { throw new NullPointerException(); } Object values = getValuesArray(); int valuesLength = Array.getLength(values); final int index = putInner(interval.getLow(), interval.getHigh()); if (index < 0) { int insertIndex = -index - 1; if (size - 1 < valuesLength) { if (insertIndex < size - 1) { System.arraycopy(values, insertIndex, values, insertIndex + 1, size - insertIndex - 1); } Array.set(values, insertIndex, value); } else { Object newArray = Array.newInstance(values.getClass().getComponentType(), valuesLength + 1); System.arraycopy(values, 0, newArray, 0, insertIndex); System.arraycopy(values, insertIndex, newArray, insertIndex + 1, valuesLength - insertIndex); Array.set(newArray, insertIndex, value); setValuesArray(newArray); } return true; } else { Array.set(values, index, value); } return false; } IntervalMap();  IntervalMap(int capacity); protected  IntervalMap(double[] keys); @Override boolean put(Interval interval, T value); @Override boolean remove(Interval interval); @Override Object get(Interval interval, Estimator estimator); @Override T get(Interval interval, T defaultValue); @Override T[] toValuesArray(); @Override int size(); @Override boolean isEmpty(); boolean contains(double timestamp); @Override boolean contains(Interval interval); @Override Interval[] toKeysArray(); double[] getIntervals(); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(TimeFormat timeFormat, DateTimeZone timeZone); @Override String toString(TimeFormat timeFormat); @Override String toString();  }