/** * Adds an A key, a B key, and a Q value at the same point in the ordering (the end) to this K2V1. Neither aKey nor * bKey can be present in this collection before this is called. If you want to change or update an existing key, * use {@link #alterA(Object, Object)} or {@link #alterB(Object, Object)}. The value, qValue, has no restrictions. * @param aKey an A key to add; cannot already be present * @param bKey a B key to add; cannot already be present * @param qValue a Q value to add; can be present any number of times * @return true if this collection changed as a result of this call */ public boolean put(A aKey, B bKey, Q qValue) { if(keys.put(aKey, bKey)) { values.add(qValue); return true; } return false; }
/** * Puts all unique A and B keys in {@code aKeys} and {@code bKeys} into this K2 at the end. If an A in aKeys or a B * in bKeys is already present when this would add one, this will not put the A and B keys at that point in the * iteration order, and will place the next unique A and B it finds in the arguments at that position instead. * @param aKeys an Iterable or Collection of A keys to add; should all be unique (like a Set) * @param bKeys an Iterable or Collection of B keys to add; should all be unique (like a Set) * @return true if this collection changed as a result of this call */ public boolean putAll(Iterable<? extends A> aKeys, Iterable<? extends B> bKeys) { if(aKeys == null || bKeys == null) return false; Iterator<? extends A> aIt = aKeys.iterator(); Iterator<? extends B> bIt = bKeys.iterator(); boolean changed = false; while (aIt.hasNext() && bIt.hasNext()) { changed = put(aIt.next(), bIt.next()) || changed; } return changed; } /**
/** * Puts all unique A and B keys in {@code other} into this K2, respecting other's ordering. If an A or a B in other * is already present when this would add one, this will not put the A and B keys at that point in the iteration * order, and will place the next unique A and B it finds in the arguments at that position instead. * @param other another K2 collection with the same A and B types * @return true if this collection changed as a result of this call */ public boolean putAll(K2<? extends A, ? extends B> other) { if(other == null) return false; boolean changed = false; int sz = other.size(); for (int i = 0; i < sz; i++) { changed = put(other.getAAt(i), other.getBAt(i)) || changed; } return changed; }
/** * Adds a bundle of E keys and a S key at the same point in the ordering (the end) to this BundleBiMap. Neither * parameter can be present in this collection before this is called. * @param e an array of E keys to add; the array cannot already be present, nor can it be null * @param s e S key to add; cannot already be present * @return true if this collection changed as e result of this call */ public boolean put(Collection<? extends E> e, S s) { if(e == null) return false; int len = elements.size; elements.putAll(e); for (int i = len; i < elements.size; i++) { mm.add(new IntVLA(e.size())); } int[][] bundle = new int[][]{elements.getArray(e)}; if(!bm.put(bundle, s)) return false; len = bundle[0].length; for (int i = 0; i < len; i++) { mm.get(bundle[0][i]).add(bm.size()-1); } return true; } /**
/** * Adds a bundle of E keys, mixed with an int array of variations, and a S key at the same point in the ordering * (the end) to this BundleBiMap. Neither the S key nor the bundle (effectively, the pair of e and variation) can be * present in this collection before this is called. * @param e an array of E keys to add; the array cannot already have been inserted with an equivalent variation, nor can it be null * @param variation an int array that can be used to make a different version of e, i.e. the same things at different quantities; cannot be null * @param s e S key to add; cannot already be present * @return true if this collection changed as e result of this call */ public boolean put(Collection<? extends E> e, int[] variation, S s) { if(e == null || variation == null) return false; int len = elements.size; elements.putAll(e); for (int i = len; i < elements.size; i++) { mm.add(new IntVLA(e.size())); } int[][] bundle = new int[][]{elements.getArray(e), variation}; if(!bm.put(bundle, s)) return false; len = bundle[0].length; for (int i = 0; i < len; i++) { mm.get(bundle[0][i]).add(bm.size()-1); } return true; }
/** * Adds a bundle of E keys, mixed with an int array of variations, and a S key at the same point in the ordering * (the end) to this BundleBiMap. Neither the S key nor the bundle (effectively, the pair of e and variation) can be * present in this collection before this is called. * @param e an array of E keys to add; the array cannot already have been inserted with an equivalent variation, nor can it be null * @param variation an int array that can be used to make a different version of e, i.e. the same things at different quantities; cannot be null * @param s e S key to add; cannot already be present * @return true if this collection changed as e result of this call */ public boolean put(E[] e, int[] variation, S s) { if(e == null || variation == null) return false; int len = elements.size; elements.putAll(e); for (int i = len; i < elements.size; i++) { mm.add(new IntVLA(e.length)); } int[][] bundle = new int[][]{elements.getArray(e), variation}; if(!bm.put(bundle, s)) return false; for (int i = 0; i < e.length; i++) { mm.get(bundle[0][i]).add(bm.size()-1); } return true; } /**
/** * Adds a bundle of E keys and a S key at the same point in the ordering (the end) to this BundleBiMap. Neither * parameter can be present in this collection before this is called. * @param e an array of E keys to add; the array cannot already be present, nor can it be null * @param s e S key to add; cannot already be present * @return true if this collection changed as e result of this call */ public boolean put(E[] e, S s) { if(e == null) return false; int len = elements.size; elements.putAll(e); for (int i = len; i < elements.size; i++) { mm.add(new IntVLA(e.length)); } elements.putAll(e); int[][] bundle = new int[][]{elements.getArray(e)}; if(!bm.put(bundle, s)) return false; for (int i = 0; i < e.length; i++) { mm.get(bundle[0][i]).add(bm.size()-1); } return true; } /**
if(!bm.put(bundle1, bundle2)) return false; len = e1.size();
if(!bm.put(bundle1, bundle2)) return false; len = e1.length;
else bundle2 = new int[][]{elements2.getArray(e2), variation2}; if(!bm.put(bundle1, bundle2)) return false; len = e1.size();
else bundle2 = new int[][]{elements2.getArray(e2), variation2}; if(!bm.put(bundle1, bundle2)) return false; len = e1.length;