/** * Given an index to look up, gets the S key present at that position in the ordering. * @param index an int index to look up * @return a 2D int array that represents a bundle, or null if index is out of bounds */ public S singleAt(int index) { return bm.getBAt(index); }
/** * Given an int index, finds the associated S key (using index as a point in the ordering). * @param index an int index into this BundleBiMap * @return the S object with index for its position in the ordering, or null if index was invalid */ public S getSingleAt(int index) { return bm.getBAt(index); }
/** * Given an int index, finds the associated B key (using index as a point in the ordering). * @param index an int index into this K2V1 * @return the B object with index for its position in the ordering, or null if index was invalid */ public B getBAt(int index) { return keys.getBAt(index); }
/** * Given an index to look up, gets the E2 key present at that position in the ordering. * @param index an int index to look up */ public OrderedSet<E2> getElement2At(int index) { return elements2.keysAt(bm.getBAt(index)[0]); }
/** * 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; }
/** * Puts all unique E and S keys in {@code other} into this K2, respecting other's ordering. If an E or a S in other * is already present when this would add one, this will not put the E and S keys at that point in the iteration * order, and will place the next unique E and S it finds in the arguments at that position instead. * @param other another K2 collection with the same E and S types * @return true if this collection changed as a result of this call */ public boolean putAll(BundleBiMap<? extends E, ? extends S> other) { if(other == null) return false; boolean changed = false; int sz = other.size(); for (int i = 0; i < sz; i++) { int[][] bundle = other.bm.getAAt(i); if(bundle == null || bundle.length == 0) continue; if(bundle.length == 1) changed |= put(elements.keysAt(bundle[0]), other.bm.getBAt(i)); else changed |= put(elements.keysAt(bundle[0]), bundle[1], other.bm.getBAt(i)); } return changed; }
/** * Puts all unique E1 and E2 keys in {@code other} into this K2, respecting other's ordering. If an E1 or a E2 in other * is already present when this would add one, this will not put the E1 and E2 keys at that point in the iteration * order, and will place the next unique E1 and E2 it finds in the arguments at that position instead. * @param other another K2 collection with the same E1 and E2 types * @return true if this collection changed as a result of this call */ public boolean putAll(BundleBundleBiMap<? extends E1, ? extends E2> other) { if(other == null) return false; boolean changed = false; int sz = other.size(); for (int i = 0; i < sz; i++) { int[][] bundle1 = other.bm.getAAt(i), bundle2 = other.bm.getBAt(i); if(bundle1 == null || bundle1.length == 0 || bundle2 == null || bundle2.length == 0) continue; if(bundle1.length == 1 && bundle2.length == 1) { changed |= put(elements1.keysAt(bundle1[0]), elements2.keysAt(bundle2[0])); } else { changed |= put(elements1.keysAt(bundle1[0]), bundle1.length > 1 ? bundle1[1] : null, elements2.keysAt(bundle2[0]), bundle2.length > 1 ? bundle2[1] : null); } } return changed; }