/** * Returns true if this contains the E, element, in any of its bundles of E keys. * @param element the E to check the presence of in all bundles * @return true if element is present in this; false otherwise */ public boolean containsElement(E element) { return elements.containsKey(element); } /**
/** * Returns true if this contains the A, key, in its collection of A items. * @param key the A to check the presence of * @return true if key is present in this; false otherwise */ public boolean containsA(A key) { return keysA.containsKey(key); } /**
public boolean contains(CharSequence item) { return names.containsKey(item); } public int indexOf(CharSequence item)
/** * Returns true if this contains the E2, element, in its collection of E2 items. * @param element the E2 to check the presence of * @return true if element is present in this; false otherwise */ public boolean containsElement2(E2 element) { return elements2.containsKey(element); }
/** * Returns true if this contains the B, key, in its collection of B items. * @param key the B to check the presence of * @return true if key is present in this; false otherwise */ public boolean containsB(B key) { return keysB.containsKey(key); }
/** * Returns true if this contains the E1, element, in any of its bundles of E1 keys. * @param element the E1 to check the presence of in all bundles * @return true if element is present in this; false otherwise */ public boolean containsElement1(E1 element) { return elements1.containsKey(element); } /**
/** * Returns true if this contains key in the keyset specified by which. * @param which which keyset to check in * @param key the key to check the presence of * @return true if key is present in the keyset at which; false otherwise */ public boolean contains(int which, Object key) { if(which >= 0 && which < keyCount) return keys[which].containsKey(key); return false; }
/** * Checks if this contains the given name. * @param name the name to check * @return true if this contains the name, false otherwise */ public boolean contains(String name) { return names.containsKey(name); }
/** * Changes an existing B key, {@code past}, to another B key, {@code future}, if past exists in this K2 * and future does not yet exist in this K2. This will retain past's point in the ordering for future, so * the associated other key(s) will still be associated in the same way. * @param past a B key, that must exist in this K2's B keys, and will be changed * @param future a B key, that cannot currently exist in this K2's B keys, but will if this succeeds * @return this for chaining */ public K2<A, B> alterB(B past, B future) { if(keysB.containsKey(past) && !keysB.containsKey(future)) keysB.alter(past, future); return this; }
/** * Changes an existing A key, {@code past}, to another A key, {@code future}, if past exists in this K2 * and future does not yet exist in this K2. This will retain past's point in the ordering for future, so * the associated other key(s) will still be associated in the same way. * @param past an A key, that must exist in this K2's A keys, and will be changed * @param future an A key, that cannot currently exist in this K2's A keys, but will if this succeeds * @return this for chaining */ public K2<A, B> alterA(A past, A future) { if(keysA.containsKey(past) && !keysA.containsKey(future)) keysA.alter(past, future); return this; }
/** * In the keyset specified by {@code which}, changes an existing key, {@code past}, to another key, {@code future}, * if past exists in that keyset and future does not yet exist in that keyset. This will retain past's point in the * ordering for future, so the associated other key(s) will still be associated in the same way. * @param which which keyset to alter the items in * @param past a key, that must exist in the keyset specified by which, and will be changed * @param future a key, that cannot currently exist in the keyset specified by which, but will if this succeeds * @return this for chaining */ public MultiKey alter(int which, Object past, Object future) { if(which >= 0 && which < keyCount && keys[which].containsKey(past) && !keys[which].containsKey(future)) keys[which].alter(past, future); return this; } /**
/** * Adds an A key and a B key at the same point in the ordering (the end) to this K2. Neither parameter 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)}. * @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 put(A a, B b) { if(!keysA.containsKey(a) && !keysB.containsKey(b)) { keysA.add(a); keysB.add(b); return true; } return false; }
/** * 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 same point in the ordering (the end) 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 put(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].add(k[i]); } 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; }
/** * Changes the A key at {@code index} to another A key, {@code future}, if index is valid and future does not * yet exist in this K2. The position in the ordering for future will be the same as index, and the same * as the key this replaced, if this succeeds, so the other key(s) at that position will still be associated in * the same way. * @param index a position in the ordering to change; must be at least 0 and less than {@link #size()} * @param future an A key, that cannot currently exist in this K2's A keys, but will if this succeeds * @return this for chaining */ public K2<A, B> alterAAt(int index, A future) { if(!keysA.containsKey(future) && index >= 0 && index < keysA.size) keysA.alter(keysA.keyAt(index), future); return this; }
/** * In the keyset specified by {@code which}, changes the key at {@code index} to another key, {@code future}, if * index is valid and future does not yet exist in that keyset. The position in the ordering for future will be the * same as index, and the same as the key this replaced, if this succeeds, so the other key(s) at that position will * still be associated in the same way. * @param which which keyset to alter the items in * @param index a position in the ordering to change; must be at least 0 and less than {@link #size()} * @param future a key, that cannot currently exist in the keyset specified by which, but will if this succeeds * @return this for chaining */ public MultiKey alterAt(int which, int index, Object future) { if(which >= 0 && which < keyCount && !keys[which].containsKey(future) && index >= 0 && index < keys[which].size) keys[which].alter(keys[which].keyAt(index), future); return this; }
/** * Changes the B key at {@code index} to another B key, {@code future}, if index is valid and future does not * yet exist in this K2. The position in the ordering for future will be the same as index, and the same * as the key this replaced, if this succeeds, so the other key(s) at that position will still be associated in * the same way. * @param index a position in the ordering to change; must be at least 0 and less than {@link #size()} * @param future a B key, that cannot currently exist in this K2's B keys, but will if this succeeds * @return this for chaining */ public K2<A, B> alterBAt(int index, B future) { if(!keysB.containsKey(future) && index >= 0 && index < keysB.size) keysB.alter(keysB.keyAt(index), future); return this; } /**