/** * Given a B object, finds the associated A object (it will be at the same point in the ordering). * @param key a B object to use as a key * @return the A object associated with key, or null if key was not present */ public A getAFromB(Object key) { return keys.getAFromB(key); } /**
/** * Looks up the StringConvert for a given vararg of Class instances (if an array of Classes is used other than a * vararg, it must not be altered in the future, nor reused in a way that modifies its elements). Returns null if no * StringConvert is found. You should usually cast the returned StringConvert, if non-null, to the specific * StringConvert generic type you want. * @param types the vararg of types to look up * @return the StringConvert registered for the given types, or null if none has been made */ public static StringConvert<?> lookup(final CharSequence... types) { return registry.getAFromB(types); }
/** * Given an S key to look up, gets a (newly-allocated) int array that is equivalent to the variation part of the * bundle corresponding to single. If there is no variation in the corresponding bundle, then this returns null. * To get the E elements that are the main part of a bundle, you can use {@link #getBundleElements(Object)}. * @param single a S key to look up * @return an int array copied from the variation part of the bundle that corresponds to single, or null if invalid */ public int[] getBundleVariation(S single) { int[][] bundle; if(single == null || (bundle = bm.getAFromB(single)) == null || bundle.length < 2 || bundle[1] == null) return null; int[] ret = new int[bundle[1].length]; System.arraycopy(bundle[1], 0, ret, 0, ret.length); return ret; }
/** * Given an S key to look up, gets a (newly-allocated) OrderedSet of E element keys corresponding to that S key. * If a variation is part of the bundle, it will not be present in this, but a copy can be retrieved with * {@link #getBundleVariation(Object)}. * @param single a S key to look up * @return an OrderedSet of the E elements used in the bundle that corresponds to single, or null if invalid */ public OrderedSet<E> getBundleElements(S single) { int[][] bundle; if(single == null || (bundle = bm.getAFromB(single)) == null || bundle.length < 1 || bundle[0] == null) return null; return elements.keysAt(bundle[0]); }
/** * Given an E2 key to look up, gets a (newly-allocated) int array that is equivalent to the variation part of the * bundle corresponding to single. If there is no variation in the corresponding bundle, then this returns null. * To get the E1 elements1 that are the main part of a bundle, you can use {@link #getBundleElements(Object[])}. * @param lookup a bundle of E2 keys to look up * @return the variation part of the E1 bundle that corresponds to the looked-up bundle, or null if invalid */ public int[] getElement1BundleVariation(E2[] lookup) { int[][] bundle; if(lookup == null || (bundle = bm.getAFromB(new int[][]{elements2.getArray(lookup)})) == null || bundle.length < 2 || bundle[1] == null) return null; int[] ret = new int[bundle[1].length]; System.arraycopy(bundle[1], 0, ret, 0, ret.length); return ret; }
/** * Given an S key to look up, gets a 2D int array representing the key's matching bundle. The bundle is likely to * use a representation for the first sub-array that will be meaningless without internal information from this * BundleBiMap, but the second sub-array, if present, should match the variation supplied with that bundle * to {@link #put(Object[], int[], Object)} or {@link #put(Collection, int[], Object)}. * <br> * This method copies the 2D int array it returns, so modifying it won't affect the original BundleBiMap. * @param single a S key to look up * @return a copied 2D int array that represents a bundle, or null if single is not present in this */ public int[][] getCode(S single) { if(single == null) return null; return ArrayTools.copy(bm.getAFromB(single)); } /**
/** * Given an E2 key to look up, gets a (newly-allocated) OrderedSet of E1 element keys corresponding to that E2 key. * If a variation is part of the bundle, it will not be present in this, but a copy can be retrieved with * {@link #getElement1BundleVariation(Object[])}. * @param lookup a E2 key to look up * @return an OrderedSet of the E1 elements1 used in the bundle that corresponds to single, or null if invalid */ public OrderedSet<E1> getBundleElements(E2[] lookup) { int[][] bundle; if(lookup == null || (bundle = bm.getAFromB(new int[][]{elements2.getArray(lookup)})) == null || bundle.length < 1 || bundle[0] == null) return null; return elements1.keysAt(bundle[0]); }