/** * Creates a new tree map copying a given map. * * @param m * a type-specific map to be copied into the new tree map. */ public Long2ObjectRBTreeMap(final Long2ObjectMap<? extends V> m) { this(); putAll(m); } /**
/** * Creates a new tree map copying a given map. * * @param m * a {@link Map} to be copied into the new tree map. */ public Long2ObjectRBTreeMap(final Map<? extends Long, ? extends V> m) { this(); putAll(m); } /**
/** * Creates a new tree map copying a given sorted map (and its * {@link Comparator}). * * @param m * a {@link SortedMap} to be copied into the new tree map. */ public Long2ObjectRBTreeMap(final SortedMap<Long, V> m) { this(m.comparator()); putAll(m); } /**
/** * Creates a new tree map copying a given sorted map (and its * {@link Comparator}). * * @param m * a type-specific sorted map to be copied into the new tree map. */ public Long2ObjectRBTreeMap(final Long2ObjectSortedMap<V> m) { this(m.comparator()); putAll(m); } /**
@Nullable public MinKSet<RowSnapshot> add(@Nullable MinKSet<RowSnapshot>left, @Nullable MinKSet<RowSnapshot> right) { assert left != null; assert right != null; Comparator<RowSnapshot> comp = left.comp; RowSnapshot minRS, maxRS; long present = left.presentCount + right.presentCount; if (left.presentCount == 0) { minRS = right.min; maxRS = right.max; } else if (right.presentCount == 0) { minRS = right.min; maxRS = right.max; } else { minRS = comp.compare(left.min, right.min) < 0 ? left.min : right.min; maxRS = comp.compare(left.max, right.max) > 0 ? left.max : right.max; } Long2ObjectRBTreeMap<RowSnapshot> data = new Long2ObjectRBTreeMap<>(); data.putAll(left.data); data.putAll(right.data); while (data.size() > this.numSamples) { long maxKey = data.lastLongKey(); data.remove(maxKey); } return new MinKSet<RowSnapshot>(this.numSamples, data, comp, minRS, maxRS, present, 0); } }