@Override protected Object getMax(Interval interval) { if (size == 0) { return null; } int[] intervals = getOverlappingIntervals(interval.getLow(), interval.getHigh()); if (intervals.length == 0) { return null; } for (int i = 0; i < intervals.length; i++) { if (getValue(intervals[i]).equals(Boolean.TRUE)) { return Boolean.TRUE; } } return Boolean.FALSE; }
/** * Returns an array of all values in this map. * <p> * This method may return a reference to the underlying array so clients * should make a copy if the array is written to. * * @return array of all values */ public boolean[] toBooleanArray() { return (boolean[]) toNativeArray(); }
/** * Get the value for the given interval. * * @param interval interval * @return found value or the default value if not found * @throws IllegalArgumentException if the element doesn't exist */ public boolean getBoolean(Interval interval) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } throw new IllegalArgumentException("The element doesn't exist"); }
private IntervalMap deserializeIntervalMap(final DataInput is) throws IOException, ClassNotFoundException { double[] intervals = (double[]) deserialize(is); Object values = deserialize(is); Class mapClass = values.getClass(); IntervalMap valueSet; if (mapClass.equals(boolean[].class)) { valueSet = new IntervalBooleanMap(intervals, (boolean[]) values); } else if (mapClass.equals(byte[].class)) { valueSet = new IntervalByteMap(intervals, (byte[]) values); } else if (mapClass.equals(char[].class)) { valueSet = new IntervalCharMap(intervals, (char[]) values); } else if (mapClass.equals(double[].class)) { valueSet = new IntervalDoubleMap(intervals, (double[]) values); } else if (mapClass.equals(float[].class)) { valueSet = new IntervalFloatMap(intervals, (float[]) values); } else if (mapClass.equals(int[].class)) { valueSet = new IntervalIntegerMap(intervals, (int[]) values); } else if (mapClass.equals(long[].class)) { valueSet = new IntervalLongMap(intervals, (long[]) values); } else if (mapClass.equals(short[].class)) { valueSet = new IntervalShortMap(intervals, (short[]) values); } else if (mapClass.equals(String[].class)) { valueSet = new IntervalStringMap(intervals, (String[]) values); } else { throw new RuntimeException("Unrecognized timestamp map class"); } return valueSet; }
private void serializeIntervalMap(final DataOutput out, final IntervalMap intervalMap) throws IOException { serialize(out, intervalMap.getIntervals()); Class mapClass = intervalMap.getClass(); if (mapClass.equals(IntervalBooleanMap.class)) { serialize(out, ((IntervalBooleanMap) intervalMap).toBooleanArray()); } else if (mapClass.equals(IntervalByteMap.class)) { serialize(out, ((IntervalByteMap) intervalMap).toByteArray()); } else if (mapClass.equals(IntervalCharMap.class)) { serialize(out, ((IntervalCharMap) intervalMap).toCharacterArray()); } else if (mapClass.equals(IntervalDoubleMap.class)) { serialize(out, ((IntervalDoubleMap) intervalMap).toDoubleArray()); } else if (mapClass.equals(IntervalFloatMap.class)) { serialize(out, ((IntervalFloatMap) intervalMap).toFloatArray()); } else if (mapClass.equals(IntervalIntegerMap.class)) { serialize(out, ((IntervalIntegerMap) intervalMap).toIntegerArray()); } else if (mapClass.equals(IntervalLongMap.class)) { serialize(out, ((IntervalLongMap) intervalMap).toLongArray()); } else if (mapClass.equals(IntervalShortMap.class)) { serialize(out, ((IntervalShortMap) intervalMap).toShortArray()); } else if (mapClass.equals(IntervalStringMap.class)) { serialize(out, intervalMap.toValuesArray()); } else { throw new RuntimeException("Unrecognized interval map class"); } }
/** * Get the value for the given interval. * * @param interval interval * @return found value or the default value if not found * @throws IllegalArgumentException if the element doesn't exist */ public boolean getBoolean(Interval interval) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } throw new IllegalArgumentException("The element doesn't exist"); }
private IntervalMap deserializeIntervalMap(final DataInput is) throws IOException, ClassNotFoundException { double[] intervals = (double[]) deserialize(is); Object values = deserialize(is); Class mapClass = values.getClass(); IntervalMap valueSet; if (mapClass.equals(boolean[].class)) { valueSet = new IntervalBooleanMap(intervals, (boolean[]) values); } else if (mapClass.equals(byte[].class)) { valueSet = new IntervalByteMap(intervals, (byte[]) values); } else if (mapClass.equals(char[].class)) { valueSet = new IntervalCharMap(intervals, (char[]) values); } else if (mapClass.equals(double[].class)) { valueSet = new IntervalDoubleMap(intervals, (double[]) values); } else if (mapClass.equals(float[].class)) { valueSet = new IntervalFloatMap(intervals, (float[]) values); } else if (mapClass.equals(int[].class)) { valueSet = new IntervalIntegerMap(intervals, (int[]) values); } else if (mapClass.equals(long[].class)) { valueSet = new IntervalLongMap(intervals, (long[]) values); } else if (mapClass.equals(short[].class)) { valueSet = new IntervalShortMap(intervals, (short[]) values); } else if (mapClass.equals(String[].class)) { valueSet = new IntervalStringMap(intervals, (String[]) values); } else { throw new RuntimeException("Unrecognized timestamp map class"); } return valueSet; }
private void serializeIntervalMap(final DataOutput out, final IntervalMap intervalMap) throws IOException { serialize(out, intervalMap.getIntervals()); Class mapClass = intervalMap.getClass(); if (mapClass.equals(IntervalBooleanMap.class)) { serialize(out, ((IntervalBooleanMap) intervalMap).toBooleanArray()); } else if (mapClass.equals(IntervalByteMap.class)) { serialize(out, ((IntervalByteMap) intervalMap).toByteArray()); } else if (mapClass.equals(IntervalCharMap.class)) { serialize(out, ((IntervalCharMap) intervalMap).toCharacterArray()); } else if (mapClass.equals(IntervalDoubleMap.class)) { serialize(out, ((IntervalDoubleMap) intervalMap).toDoubleArray()); } else if (mapClass.equals(IntervalFloatMap.class)) { serialize(out, ((IntervalFloatMap) intervalMap).toFloatArray()); } else if (mapClass.equals(IntervalIntegerMap.class)) { serialize(out, ((IntervalIntegerMap) intervalMap).toIntegerArray()); } else if (mapClass.equals(IntervalLongMap.class)) { serialize(out, ((IntervalLongMap) intervalMap).toLongArray()); } else if (mapClass.equals(IntervalShortMap.class)) { serialize(out, ((IntervalShortMap) intervalMap).toShortArray()); } else if (mapClass.equals(IntervalStringMap.class)) { serialize(out, intervalMap.toValuesArray()); } else { throw new RuntimeException("Unrecognized interval map class"); } }
@Override protected Object getMax(Interval interval) { if (size == 0) { return null; } int[] intervals = getOverlappingIntervals(interval.getLow(), interval.getHigh()); if (intervals.length == 0) { return null; } for (int i = 0; i < intervals.length; i++) { if (getValue(intervals[i]).equals(Boolean.TRUE)) { return Boolean.TRUE; } } return Boolean.FALSE; }
/** * Get the value for the given interval. * <p> * Return <code>defaultValue</code> if the value is not found. * * @param interval interval * @param defaultValue default value * @return found value or the default value if not found */ public boolean getBoolean(Interval interval, boolean defaultValue) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } return defaultValue; }
result = new IntervalDoubleMap(capacity); } else if (typeClass.equals(Boolean.class)) { result = new IntervalBooleanMap(capacity); } else if (typeClass.equals(Character.class)) { result = new IntervalCharMap(capacity);
/** * Returns an array of all values in this map. * <p> * This method may return a reference to the underlying array so clients * should make a copy if the array is written to. * * @return array of all values */ public boolean[] toBooleanArray() { return (boolean[]) toNativeArray(); }
@Override protected Object getMin(Interval interval) { if (size == 0) { return null; } int[] intervals = getOverlappingIntervals(interval.getLow(), interval.getHigh()); if (intervals.length == 0) { return null; } for (int i = 0; i < intervals.length; i++) { if (getValue(intervals[i]).equals(Boolean.FALSE)) { return Boolean.FALSE; } } return Boolean.TRUE; }
/** * Get the value for the given interval. * <p> * Return <code>defaultValue</code> if the value is not found. * * @param interval interval * @param defaultValue default value * @return found value or the default value if not found */ public boolean getBoolean(Interval interval, boolean defaultValue) { final int index = getIndex(interval.getLow(), interval.getHigh()); if (index >= 0) { return values[index / 2]; } return defaultValue; }
result = new IntervalDoubleMap(capacity); } else if (typeClass.equals(Boolean.class)) { result = new IntervalBooleanMap(capacity); } else if (typeClass.equals(Character.class)) { result = new IntervalCharMap(capacity);
@Override protected Object getMin(Interval interval) { if (size == 0) { return null; } int[] intervals = getOverlappingIntervals(interval.getLow(), interval.getHigh()); if (intervals.length == 0) { return null; } for (int i = 0; i < intervals.length; i++) { if (getValue(intervals[i]).equals(Boolean.FALSE)) { return Boolean.FALSE; } } return Boolean.TRUE; }