/** * Creates a new tree map using the elements of two parallel arrays and the * given comparator. * * @param k * the array of keys of the new tree map. * @param v * the array of corresponding values in the new tree map. * @param c * a (possibly type-specific) comparator. * @throws IllegalArgumentException * if {@code k} and {@code v} have different lengths. */ public Int2ObjectRBTreeMap(final int[] k, final V v[], final Comparator<? super Integer> c) { this(c); if (k.length != v.length) throw new IllegalArgumentException( "The key array and the value array have different lengths (" + k.length + " and " + v.length + ")"); for (int i = 0; i < k.length; i++) this.put(k[i], v[i]); } /**
public void push(final int intVal) { if (this.size == 0) { this.data.put(intVal, new MutableInteger(1)); // Add newVal to Top K this.cutoff = intVal; this.size = 1; counter.set(count); } else { // Add a new key to Top K this.data.put(intVal, new MutableInteger(1)); if (this.size >= this.maxSize) { // Remove the largest key, compute the new largest key this.data.remove(this.cutoff); if (this.size < this.maxSize) { // Only case where newVal needs to be added this.size += 1; this.data.put(intVal, new MutableInteger(1)); // Add newVal to Top K this.cutoff = intVal; // It is now the largest value