/** * Returns an iterable yielding a bidirectional iterator that will be * {@linkplain FastSortedEntrySet fast}, if possible, on the * {@linkplain Map#entrySet() entry set} of the provided {@code map}. * * @param map * a map from which we will try to extract an iterable yielding a * (fast) bidirectional iterator on the entry set. * @return an iterable yielding a bidirectional iterator on the entry set of the * given map that will be fast, if possible. * @since 8.0.0 */ public static ObjectBidirectionalIterable<Double2IntMap.Entry> fastIterable(Double2IntSortedMap map) { final ObjectSortedSet<Double2IntMap.Entry> entries = map.double2IntEntrySet(); return entries instanceof Double2IntSortedMap.FastSortedEntrySet ? ((Double2IntSortedMap.FastSortedEntrySet) entries)::fastIterator : entries; } /**
/** * Returns a sorted-set view of the mappings contained in this map. * <p> * Note that this specification strengthens the one given in the corresponding * type-specific unsorted map. * * @return a sorted-set view of the mappings contained in this map. * @see SortedMap#entrySet() * @deprecated Please use the corresponding type-specific method instead. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Deprecated @Override default ObjectSortedSet<Map.Entry<Double, Integer>> entrySet() { return (ObjectSortedSet) double2IntEntrySet(); } /**
@Override public ObjectSortedSet<Double2IntMap.Entry> double2IntEntrySet() { if (entries == null) entries = ObjectSortedSets.synchronize(sortedMap.double2IntEntrySet(), sync); return (ObjectSortedSet<Double2IntMap.Entry>) entries; } /**
@Override public ObjectSortedSet<Double2IntMap.Entry> double2IntEntrySet() { if (entries == null) entries = ObjectSortedSets.unmodifiable(sortedMap.double2IntEntrySet()); return (ObjectSortedSet<Double2IntMap.Entry>) entries; } /**
@Override public ObjectSortedSet<Double2IntMap.Entry> tailSet(Double2IntMap.Entry from) { return tailMap(from.getDoubleKey()).double2IntEntrySet(); } };
@Override public ObjectSortedSet<Double2IntMap.Entry> headSet(Double2IntMap.Entry to) { return headMap(to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public ObjectSortedSet<Double2IntMap.Entry> headSet(Double2IntMap.Entry to) { return headMap(to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public ObjectSortedSet<Double2IntMap.Entry> headSet(Double2IntMap.Entry to) { return headMap(to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public ObjectSortedSet<Double2IntMap.Entry> tailSet(Double2IntMap.Entry from) { return tailMap(from.getDoubleKey()).double2IntEntrySet(); } };
@Override public ObjectSortedSet<Double2IntMap.Entry> tailSet(Double2IntMap.Entry from) { return tailMap(from.getDoubleKey()).double2IntEntrySet(); } };
@Override public ObjectSortedSet<Double2IntMap.Entry> headSet(Double2IntMap.Entry to) { return headMap(to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public ObjectSortedSet<Double2IntMap.Entry> tailSet(Double2IntMap.Entry from) { return tailMap(from.getDoubleKey()).double2IntEntrySet(); } };
/** * Returns a bidirectional iterator that will be {@linkplain FastSortedEntrySet * fast}, if possible, on the {@linkplain Map#entrySet() entry set} of the * provided {@code map}. * * @param map * a map from which we will try to extract a (fast) bidirectional * iterator on the entry set. * @return a bidirectional iterator on the entry set of the given map that will * be fast, if possible. * @since 8.0.0 */ public static ObjectBidirectionalIterator<Double2IntMap.Entry> fastIterator(Double2IntSortedMap map) { final ObjectSortedSet<Double2IntMap.Entry> entries = map.double2IntEntrySet(); return entries instanceof Double2IntSortedMap.FastSortedEntrySet ? ((Double2IntSortedMap.FastSortedEntrySet) entries).fastIterator() : entries.iterator(); } /**
@Override public ObjectSortedSet<Double2IntMap.Entry> subSet(Double2IntMap.Entry from, Double2IntMap.Entry to) { return subMap(from.getDoubleKey(), to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public ObjectSortedSet<Double2IntMap.Entry> subSet(Double2IntMap.Entry from, Double2IntMap.Entry to) { return subMap(from.getDoubleKey(), to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public ObjectSortedSet<Double2IntMap.Entry> subSet(Double2IntMap.Entry from, Double2IntMap.Entry to) { return subMap(from.getDoubleKey(), to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public ObjectSortedSet<Double2IntMap.Entry> subSet(Double2IntMap.Entry from, Double2IntMap.Entry to) { return subMap(from.getDoubleKey(), to.getDoubleKey()).double2IntEntrySet(); } @Override
@Override public double getMaxTimestamp() { if (mainIndex) { Double2IntSortedMap sortedMap = (Double2IntSortedMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { return sortedMap.lastDoubleKey(); } } else { Double2IntSortedMap sortedMap = (Double2IntSortedMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { ObjectBidirectionalIterator<Double2IntMap.Entry> bi = sortedMap.double2IntEntrySet().iterator(sortedMap .double2IntEntrySet().last()); while (bi.hasPrevious()) { Double2IntMap.Entry entry = bi.previous(); double timestamp = entry.getDoubleKey(); int index = entry.getIntValue(); if (index < timestamps.length) { TimeIndexEntry timestampEntry = timestamps[index]; if (timestampEntry != null) { return timestamp; } } } } } return Double.POSITIVE_INFINITY; }
@Override public double getMinTimestamp() { if (mainIndex) { Double2IntSortedMap sortedMap = (Double2IntSortedMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { return sortedMap.firstDoubleKey(); } } else { Double2IntSortedMap sortedMap = (Double2IntSortedMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { ObjectBidirectionalIterator<Double2IntMap.Entry> bi = sortedMap.double2IntEntrySet().iterator(); while (bi.hasNext()) { Double2IntMap.Entry entry = bi.next(); double timestamp = entry.getDoubleKey(); int index = entry.getIntValue(); if (index < timestamps.length) { TimeIndexEntry timestampEntry = timestamps[index]; if (timestampEntry != null) { return timestamp; } } } } } return Double.NEGATIVE_INFINITY; }
Double2IntSortedMap sortedMap = (Double2IntSortedMap) timestampIndexStore.timeSortedMap; if (!sortedMap.isEmpty()) { for (Double2IntMap.Entry entry : sortedMap.tailMap(interval.getLow()).double2IntEntrySet()) { double timestamp = entry.getDoubleKey(); int index = entry.getIntValue();