/** * Returns a separate (shallow) copy of the set of B keys as an {@link OrderedSet}. * To be called sparingly, since this allocates a new OrderedSet instead of reusing one. This can be useful if you * were going to copy the set produced by {@link #getSetB()} anyway. * @return the B keys as an OrderedSet */ public OrderedSet<B> getOrderedSetB() { return keysB.keysAsOrderedSet(); }
/** * Returns a separate (shallow) copy of the set of A keys as an {@link OrderedSet}. * To be called sparingly, since this allocates a new OrderedSet instead of reusing one. This can be useful if you * were going to copy the set produced by {@link #getSetA()} anyway. * @return the A keys as an OrderedSet */ public OrderedSet<A> getOrderedSetA() { return keysA.keysAsOrderedSet(); }
/** * To be called sparingly, since this allocates a new OrderedSet instead of reusing one. * @return the E1 keys as an OrderedSet */ public OrderedSet<E1> getElement1OrderedSet() { return elements1.keysAsOrderedSet(); }
/** * To be called sparingly, since this allocates a new OrderedSet instead of reusing one. * @param which which keyset to get as a separate value * @return the keys from the keyset specified by which, as an OrderedSet */ public OrderedSet getOrderedSet(int which) { if(which >= 0 && which < keyCount) return keys[which].keysAsOrderedSet(); return null; }
/** * To be called sparingly, since this allocates a new OrderedSet instead of reusing one. * @return the E keys as an OrderedSet */ public OrderedSet<E> getElementOrderedSet() { return elements.keysAsOrderedSet(); }
/** * To be called sparingly, since this allocates a new OrderedSet instead of reusing one. * @return the E2 keys as an OrderedSet */ public OrderedSet<E2> getElement2OrderedSet() { return elements2.keysAsOrderedSet(); }
/** * Provides a set of the items in this table, without reference to their * weight. Includes nested ProbabilityTable values, but as is the case throughout * this class, cyclical references to ProbabilityTable values that reference this * table will result in significant issues (such as a {@link StackOverflowError} * crashing your program). * * @return an OrderedSet of all items stored; iteration order should be predictable */ public OrderedSet<T> items() { OrderedSet<T> os = table.keysAsOrderedSet(); for (int i = 0; i < extraTable.size(); i++) { os.addAll(extraTable.get(i).items()); } return os; }
@Override public void write(Json json, Arrangement object, Class knownType) { if(object == null) { json.writeValue(null); return; } json.writeObjectStart(); json.writeValue("k", object.keysAsOrderedSet(), OrderedSet.class); json.writeValue("f", object.f); json.writeObjectEnd(); }