/** * 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; } /**
@Override public double firstDoubleKey() { synchronized (sync) { return sortedMap.firstDoubleKey(); } } @Override
@Override public double lastDoubleKey() { return sortedMap.lastDoubleKey(); } /**
@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; }
ObjectSet<Element> elements = new ObjectOpenHashSet<Element>(); 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();
/** * {@inheritDoc} * <p> * Note that this specification strengthens the one given in * {@link SortedMap#tailMap(Object)}. * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Double2IntSortedMap tailMap(final Double from) { return tailMap((from).doubleValue()); } /**
for (int i = 0; i < rawEstForP.length; i++) { distance = Math.pow(count - rawEstForP[i], 2); estIndexMap.put(distance, i); double biasSum = 0; int kNeighbors = HLLConstants.K_NEAREST_NEIGHBOR; for (Map.Entry<Double, Integer> entry : estIndexMap.entrySet()) { biasSum += biasForP[entry.getValue()]; kNeighbors--;
@Override public DoubleSortedSet headSet(final double to) { return headMap(to).keySet(); } @Override
/** * {@inheritDoc} * <p> * Note that this specification strengthens the one given in * {@link SortedMap#headMap(Object)}. * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Double2IntSortedMap headMap(final Double to) { return headMap((to).doubleValue()); } /**
@Override public DoubleComparator comparator() { synchronized (sync) { return sortedMap.comparator(); } } @Override
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Double firstKey() { return sortedMap.firstKey(); } /**
@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; }
ObjectSet<Element> elements = new ObjectOpenHashSet<Element>(); 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();
@Override public Double2IntSortedMap tailMap(final double from) { return new SynchronizedSortedMap(sortedMap.tailMap(from), sync); } @Override
@Override public DoubleSortedSet tailSet(final double from) { return tailMap(from).keySet(); } @Override
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Double2IntSortedMap headMap(final Double to) { return new SynchronizedSortedMap(sortedMap.headMap(to), sync); } /**
@Override public DoubleComparator comparator() { return sortedMap.comparator(); } @Override
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Double firstKey() { synchronized (sync) { return sortedMap.firstKey(); } } /**