GroupQueue(final int maxSize) { this.maxSize = maxSize; groupLeaders = new HashMap<>(); scoreGroups = new Float2ReferenceRBTreeMap<>(); }
@Override public V put(final float k, final V v) { Entry<V> e = add(k); final V oldValue = e.value; e.value = v; return oldValue; } /**
@Override public void clear() { Float2ReferenceRBTreeMap.this.clear(); } };
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); /* * The storedComparator is now correctly set, but we must restore on-the-fly the * actualComparator. */ setActualComparator(); allocatePaths(); if (count != 0) { tree = readTree(s, count, null, null); Entry<V> e; e = tree; while (e.left() != null) e = e.left(); firstEntry = e; e = tree; while (e.right() != null) e = e.right(); lastEntry = e; } } }
/** * Creates a new tree map copying a given map. * * @param m * a type-specific map to be copied into the new tree map. */ public Float2ReferenceRBTreeMap(final Float2ReferenceMap<? extends V> m) { this(); putAll(m); } /**
/** * Returns the entry corresponding to the given key, if it is in the tree; * {@code null}, otherwise. * * @param k * the key to search for. * @return the corresponding entry, or {@code null} if no entry with the given * key exists. */ final Entry<V> findKey(final float k) { Entry<V> e = tree; int cmp; while (e != null && (cmp = compare(k, e.key)) != 0) e = cmp < 0 ? e.left() : e.right(); return e; } /**
@Override public V get(final float k) { final Entry<V> e = findKey(k); return e == null ? defRetValue : e.value; } @Override
/** * Creates a new empty tree map with the given comparator. * * @param c * a (possibly type-specific) comparator. */ public Float2ReferenceRBTreeMap(final Comparator<? super Float> c) { this(); storedComparator = c; setActualComparator(); } /**
/** * 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 Float2ReferenceRBTreeMap(final float[] k, final V v[], final Comparator<? super Float> 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]); } /**
c.values = null; c.entries = null; c.allocatePaths(); if (count != 0) {
/** * Creates a new tree map copying a given map. * * @param m * a {@link Map} to be copied into the new tree map. */ public Float2ReferenceRBTreeMap(final Map<? extends Float, ? extends V> m) { this(); putAll(m); } /**
/** * Locates a key. * * @param k * a key. * @return the last entry on a search for the given key; this will be the given * key, if it present; otherwise, it will be either the smallest greater * key or the greatest smaller key. */ final Entry<V> locateKey(final float k) { Entry<V> e = tree, last = tree; int cmp = 0; while (e != null && (cmp = compare(k, e.key)) != 0) { last = e; e = cmp < 0 ? e.left() : e.right(); } return cmp == 0 ? e : last; } /**
@Override public boolean containsKey(final float k) { return findKey(k) != null; } @Override
/** * 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 Float2ReferenceRBTreeMap(final SortedMap<Float, V> m) { this(m.comparator()); putAll(m); } /**
int cmp, i = 0; while (true) { if ((cmp = compare(k, p.key)) == 0) {
/** * 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 Float2ReferenceRBTreeMap(final Float2ReferenceSortedMap<V> m) { this(m.comparator()); putAll(m); } /**
final float kk = k; while (true) { if ((cmp = compare(kk, p.key)) == 0) break; dirPath[i] = cmp > 0;