/** * Construct a Spill without a level to actually scan. This constructor allows you to specify a StatefulRandomness * such as Lathe32RNG, which will be referenced in this class (if the state of random changes because this * object needed a random number, the state change will be reflected in the code that passed random to here). * * If you use this constructor, you must call an initialize() method before using this class. */ public Spill(IStatefulRNG random) { rng = random; fresh = new OrderedSet<>(); }
public Set<Entry<Integer, Double>> toBoxed() { return new OrderedSet<Entry<Integer, Double>>(this); } }
private static OrderedSet<Coord> arrayToSet(Coord[] arr) { return new OrderedSet<> (arr); } }
/** * Makes an OrderedSet (OS) of T given an array or vararg of T elements. Duplicate items in elements will have * all but one item discarded, using the later item in elements. * @param elements an array or vararg of T * @param <T> just about any non-primitive type * @return a newly-allocated OrderedSet containing all of the non-duplicate items in elements, in order */ @SuppressWarnings("unchecked") public static <T> OrderedSet<T> makeOS(T... elements) { if(elements == null) return null; return new OrderedSet<>(elements); } /**
/** * Construct a Spill without a level to actually scan. If you use this constructor, you must call an * initialize() method before using this class. */ public Spill() { rng = new GWTRNG(); fresh = new OrderedSet<>(); } /**
public OrderedSet<K> keysAt(int... positions) { if(keys == null || positions == null || positions.length <= 0) return new OrderedSet<K>(); OrderedSet<K> ks = new OrderedSet<>(positions.length); for(int i = 0; i < positions.length; i++) { ks.add(keyAt(positions[i])); } return ks; } public OrderedSet<K> keysAt(IntVLA positions)
/** * Get a Set of all identities used for values in this data structure, returning a OrderedSet (defensively * copying the key set used internally) for its stable iteration order. * @return a OrderedSet of I corresponding to the identities present in this data structure. */ public OrderedSet<I> identities() { return new OrderedSet<>(itemMapping.keySet()); }
public OrderedSet<K> keysAt(int... positions) { if(keys == null || positions == null || positions.length <= 0) return new OrderedSet<K>(); OrderedSet<K> ks = new OrderedSet<>(positions.length); for(int i = 0; i < positions.length; i++) { ks.add(keyAt(positions[i])); } return ks; } public OrderedSet<K> keysAt(IntVLA positions)
/** * Get a Set of all positions used for values in this data structure, returning a OrderedSet (defensively copying * the key set used internally) for its stable iteration order. * @return a OrderedSet of Coord corresponding to the positions present in this data structure. */ public OrderedSet<Coord> positions() { return new OrderedSet<>(positionMapping.keySet()); } /**
/** * Quickly determines if a region is contained in one of the given packed arrays, without unpacking them, and * returns true if the region checking has some overlap with any of the packed arrays, or false otherwise. * @param checking the packed data to check for overlap with the other regions * @param packed an array or vararg of short[], such as those returned by pack() or one of the sub-arrays in what is * returned by packMulti(); null elements in packed will be skipped * @return true if checking overlaps with any of the packed arrays, or false otherwise */ public static boolean regionsContain(short[] checking, short[] ... packed) { OrderedSet<short[]> packs = new OrderedSet<>(packed.length, CrossHash.shortHasher); for (int a = 0; a < packed.length; a++) { if(packed[a] == null) continue; if(intersects(checking, packed[a])) return true; } return false; } /**
public OrderedSet<K> keysAt(IntVLA positions) { if(keys == null || positions == null || positions.size <= 0) return new OrderedSet<K>(); OrderedSet<K> ks = new OrderedSet<>(positions.size); for(int i = 0; i < positions.size; i++) { ks.add(keyAt(positions.get(i))); } return ks; }
public OrderedSet<K> keysAt(IntVLA positions) { if(keys == null || positions == null || positions.size <= 0) return new OrderedSet<K>(); OrderedSet<K> ks = new OrderedSet<>(positions.size); for(int i = 0; i < positions.size; i++) { ks.add(keyAt(positions.get(i))); } return ks; }
public static OrderedSet<GreasedRegion> whichContain(int x, int y, Collection<GreasedRegion> packed) { OrderedSet<GreasedRegion> found = new OrderedSet<>(packed.size()); for (GreasedRegion tmp : packed) { if(tmp != null && tmp.contains(x, y)) found.add(tmp); } return found; }
public OrderedSet<Integer> keysAsOrderedSet() { OrderedSet<Integer> os = new OrderedSet<>(size, f); for (int i = 0; i < size; i++) { os.add(keyAt(i)); } return os; } public int[] keysAsArray() {
public OrderedSet<K> keysAsOrderedSet() { OrderedSet<K> os = new OrderedSet<>(size, f, hasher); for (int i = 0; i < size; i++) { os.add(keyAt(i)); } return os; }
public static OrderedSet<GreasedRegion> whichContain(int x, int y, GreasedRegion ... packed) { OrderedSet<GreasedRegion> found = new OrderedSet<>(packed.length); GreasedRegion tmp; for (int i = 0; i < packed.length; i++) { if((tmp = packed[i]) != null && tmp.contains(x, y)) found.add(tmp); } return found; }
public OrderedSet<K> keysAsOrderedSet() { OrderedSet<K> os = new OrderedSet<K>(size, f, hasher); for (int i = 0; i < size; i++) { os.add(keyAt(i)); } return os; }
/** * Construct a Spill without a level to actually scan. This constructor allows you to specify an RNG, but the actual * RandomnessSource the RNG that this object uses will not be identical to the one passed as random (two ints will * be requested from the passed RNG, and that will be used to seed this class' RNG). * * If you use this constructor, you must call an initialize() method before using this class. */ public Spill(IRNG random) { rng = new GWTRNG(random.nextInt(), random.nextInt()); fresh = new OrderedSet<>(); }
@Override public OrderedSet<K> restore(String text) { ObText.ContentMatcher m = makeMatcher(text); OrderedSet<K> d; if(convert.isArray) d = new OrderedSet<>(CrossHash.generalHasher); else d = new OrderedSet<>(); while (m.find()) { if (m.hasMatch()) { d.add(convert.restore(m.getMatch())); } } return d; } };
/** * Gets all unique Strings from the top level of this ObText, not including any associated values, and puts them in * an {@link OrderedSet} of String. The returned set will retain the same order the Strings were entered in, and you * can use OrderedSet methods like {@link OrderedSet#getAt(int)} to look up keys by index. Changes to the returned * Set won't be reflected in this ObText. * @return all unique top-level Strings (without associated values) as an OrderedSet of String keys */ public OrderedSet<String> keyOrderedSet() { final int sz = size(); OrderedSet<String> keys = new OrderedSet<>(sz, CrossHash.stringHasher); for (int i = 0; i < sz; i++) { keys.add(get(i).primary); } return keys; }