/** * Adds an A key and a B key at the given index in the ordering to this K2. Neither a nor b 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 index this is given should be at * least 0 and no greater than {@link #size()}. * @param index the point in the ordering to place a and b into; later entries will be shifted forward * @param a an A key to add; cannot already be present * @param b a B key to add; cannot already be present * @return true if this collection changed as a result of this call */ public boolean putAt(int index, A a, B b) { if(!keysA.containsKey(a) && !keysB.containsKey(b)) { keysA.addAt(index, a); keysB.addAt(index, b); return true; } return false; }
/** * Adds a key to each keyset at the given index in the ordering of this MultiKey. The length of k must * match the keyCount of this MultiKey, and the nth item in k will go into the nth keyset. No item in k can be * present in the matching keyset in this before this is called. If you want to change or update an existing key, * use {@link #alter(int, Object, Object)} or {@link #alterAt(int, int, Object)}. * @param k an array or varargs of keys to add after the last index of this MultiKey; length must equal keyCount * @return true if this collection changed as a result of this call */ public boolean putAt(int index, Object... k) { if(k != null && keyCount > 0 && k.length == keyCount) { for (int i = 0; i < keyCount; i++) { if(keys[i].containsKey(k[i])) return false; } for (int i = 0; i < keyCount; i++) { keys[i].addAt(index, k[i]); } return true; } return false; }