Class CoordOrderedSet
- All Implemented Interfaces:
com.github.tommyettinger.ds.Arrangeable, com.github.tommyettinger.ds.EnhancedCollection<Coord>, com.github.tommyettinger.ds.Ordered<Coord>, com.github.yellowstonegames.core.ISerializersNeeded, Iterable<Coord>, Collection<Coord>, Set<Coord>
public class CoordOrderedSet
extends com.github.tommyettinger.ds.ObjectOrderedSet<Coord>
implements com.github.yellowstonegames.core.ISerializersNeeded
A variant on jdkgdxds'
If no initialCapacity is supplied, or if this must resize to enter a Coord, this will use a capacity at least as large as the Coord cache, as defined by
This tends to perform significantly better with a high low factor, such as 0.9f, instead of a lower one like 0.5f . It also performs its best when the initial capacity is sufficient to hold every item this needs without resizing, but it typically only has to resize once if it has to resize at all.
ObjectOrderedSet class that only holds Coord items, and can do so more efficiently.
This assumes all Coord keys are in the Coord pool; that is, Coord.expandPoolTo(int, int) has been called with
the maximum values for Coord x and y. If you cannot be sure that the Coord pool will hold items placed into here, you
should use a normal ObjectOrderedSet instead, since some optimizations here require Coord items to be in the
pool.
If no initialCapacity is supplied, or if this must resize to enter a Coord, this will use a capacity at least as large as the Coord cache, as defined by
Coord.getCacheWidth() by Coord.getCacheHeight(). While this
means that any resizing will potentially make this use much more memory, it avoids a situation where some dense key
sets could take hundreds of times longer than they should. It also usually doesn't use drastically more memory unless
the Coord pool has been expanded quite a bit. If the Coord pool hasn't been expanded, each set should use about 1MB
of memory or less when created with the default constructor, plus size proportional to ObjectSet.size() for the order.
This tends to perform significantly better with a high low factor, such as 0.9f, instead of a lower one like 0.5f . It also performs its best when the initial capacity is sufficient to hold every item this needs without resizing, but it typically only has to resize once if it has to resize at all.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.tommyettinger.ds.ObjectOrderedSet
com.github.tommyettinger.ds.ObjectOrderedSet.ObjectOrderedSetIterator<K>Nested classes/interfaces inherited from class com.github.tommyettinger.ds.ObjectSet
com.github.tommyettinger.ds.ObjectSet.ObjectSetIterator<T>Nested classes/interfaces inherited from interface com.github.tommyettinger.ds.Arrangeable
com.github.tommyettinger.ds.Arrangeable.ArrangeableList<T>Nested classes/interfaces inherited from interface com.github.tommyettinger.ds.Ordered
com.github.tommyettinger.ds.Ordered.OfBoolean, com.github.tommyettinger.ds.Ordered.OfByte, com.github.tommyettinger.ds.Ordered.OfChar, com.github.tommyettinger.ds.Ordered.OfDouble, com.github.tommyettinger.ds.Ordered.OfFloat, com.github.tommyettinger.ds.Ordered.OfInt, com.github.tommyettinger.ds.Ordered.OfLong, com.github.tommyettinger.ds.Ordered.OfShort -
Field Summary
Fields inherited from class com.github.tommyettinger.ds.ObjectOrderedSet
itemsFields inherited from class com.github.tommyettinger.ds.ObjectSet
keyTable, loadFactor, mask, shift, size, threshold -
Constructor Summary
ConstructorsConstructorDescriptionCoordOrderedSet(int initialCapacity) CoordOrderedSet(int initialCapacity, float loadFactor) CoordOrderedSet(int initialCapacity, float loadFactor, com.github.tommyettinger.ds.OrderType type) CoordOrderedSet(int initialCapacity, com.github.tommyettinger.ds.OrderType type) CoordOrderedSet(com.github.tommyettinger.ds.ObjectOrderedSet<? extends Coord> set) CoordOrderedSet(com.github.tommyettinger.ds.ObjectOrderedSet<? extends Coord> set, com.github.tommyettinger.ds.OrderType type) CoordOrderedSet(com.github.tommyettinger.ds.OrderType type) CoordOrderedSet(Coord[] items) CoordOrderedSet(Coord[] array, int offset, int length) CoordOrderedSet(Coord[] array, int offset, int length, com.github.tommyettinger.ds.OrderType type) CoordOrderedSet(Coord[] items, com.github.tommyettinger.ds.OrderType type) CoordOrderedSet(Collection<? extends Coord> coll) CoordOrderedSet(Collection<? extends Coord> coll, com.github.tommyettinger.ds.OrderType type) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected intprotected voidresize(int newSize) static CoordOrderedSetwith()Constructs an empty set given the type as a generic type argument.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given item, but can be resized.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given items, but can be resized.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given items, but can be resized.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given items, but can be resized.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given items, but can be resized.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given items, but can be resized.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given items, but can be resized.static CoordOrderedSetCreates a new CoordOrderedSet that holds only the given items, but can be resized.static CoordOrderedSetwith(Coord item0, Coord item1, Coord item2, Coord item3, Coord item4, Coord item5, Coord item6, Coord item7) Creates a new CoordOrderedSet that holds only the given items, but can be resized.Methods inherited from class com.github.tommyettinger.ds.ObjectOrderedSet
add, add, addAll, addAll, alter, alterAt, appendTo, clear, clear, ensureCapacity, first, getAt, hashCode, iterator, order, parse, parse, parse, remove, removeAt, removeRange, sort, sort, toString, toString, truncate, with, with, with, with, with, with, with, with, withMethods inherited from class com.github.tommyettinger.ds.ObjectSet
addAll, addAll, addAll, addAll, addResize, contains, containsAll, containsAll, containsAll, containsAny, containsAny, containsAnyIterable, equals, get, getHashMultiplier, getLoadFactor, getTableSize, isEmpty, locateKey, notEmpty, removeAll, removeAll, removeAll, retainAll, setHashMultiplier, setLoadFactor, shrink, size, toArray, toArrayMethods inherited from interface com.github.tommyettinger.ds.Arrangeable
rearrange, shuffle, sizeMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface com.github.tommyettinger.ds.EnhancedCollection
add, add, add, addAll, addAllIterable, addLegible, addLegible, addVarargs, appendTo, appendTo, containsAll, containsAllIterable, containsAny, removeAll, removeAllIterable, removeEach, removeEach, removeEach, removeEachIterable, toString, toStringMethods inherited from interface com.github.tommyettinger.ds.Ordered
getOrderType, random, random, reverse, selectRanked, selectRankedIndex, shuffle, swapMethods inherited from interface Set
spliterator
-
Constructor Details
-
CoordOrderedSet
public CoordOrderedSet(com.github.tommyettinger.ds.OrderType type) -
CoordOrderedSet
public CoordOrderedSet(int initialCapacity, float loadFactor, com.github.tommyettinger.ds.OrderType type) -
CoordOrderedSet
public CoordOrderedSet(int initialCapacity, com.github.tommyettinger.ds.OrderType type) -
CoordOrderedSet
public CoordOrderedSet(com.github.tommyettinger.ds.ObjectOrderedSet<? extends Coord> set, com.github.tommyettinger.ds.OrderType type) -
CoordOrderedSet
public CoordOrderedSet(Collection<? extends Coord> coll, com.github.tommyettinger.ds.OrderType type) -
CoordOrderedSet
public CoordOrderedSet(Coord[] array, int offset, int length, com.github.tommyettinger.ds.OrderType type) -
CoordOrderedSet
-
CoordOrderedSet
public CoordOrderedSet() -
CoordOrderedSet
public CoordOrderedSet(int initialCapacity, float loadFactor) -
CoordOrderedSet
public CoordOrderedSet(int initialCapacity) -
CoordOrderedSet
-
CoordOrderedSet
-
CoordOrderedSet
-
CoordOrderedSet
-
-
Method Details
-
place
-
equate
-
resize
protected void resize(int newSize) - Overrides:
resizein classcom.github.tommyettinger.ds.ObjectSet<Coord>
-
with
Constructs an empty set given the type as a generic type argument. This is usually less useful than just using the constructor, but can be handy in some code-generation scenarios when you don't know how many arguments you will have.- Returns:
- a new set containing nothing
-
with
Creates a new CoordOrderedSet that holds only the given item, but can be resized.- Parameters:
item- one Coord item- Returns:
- a new CoordOrderedSet that holds the given item
-
with
Creates a new CoordOrderedSet that holds only the given items, but can be resized.- Parameters:
item0- a Coord itemitem1- a Coord item- Returns:
- a new CoordOrderedSet that holds the given items
-
with
Creates a new CoordOrderedSet that holds only the given items, but can be resized.- Parameters:
item0- a Coord itemitem1- a Coord itemitem2- a Coord item- Returns:
- a new CoordOrderedSet that holds the given items
-
with
Creates a new CoordOrderedSet that holds only the given items, but can be resized.- Parameters:
item0- a Coord itemitem1- a Coord itemitem2- a Coord itemitem3- a Coord item- Returns:
- a new CoordOrderedSet that holds the given items
-
with
Creates a new CoordOrderedSet that holds only the given items, but can be resized.- Parameters:
item0- a Coord itemitem1- a Coord itemitem2- a Coord itemitem3- a Coord itemitem4- a Coord item- Returns:
- a new CoordOrderedSet that holds the given items
-
with
public static CoordOrderedSet with(Coord item0, Coord item1, Coord item2, Coord item3, Coord item4, Coord item5) Creates a new CoordOrderedSet that holds only the given items, but can be resized.- Parameters:
item0- a Coord itemitem1- a Coord itemitem2- a Coord itemitem3- a Coord itemitem4- a Coord itemitem5- a Coord item- Returns:
- a new CoordOrderedSet that holds the given items
-
with
public static CoordOrderedSet with(Coord item0, Coord item1, Coord item2, Coord item3, Coord item4, Coord item5, Coord item6) Creates a new CoordOrderedSet that holds only the given items, but can be resized.- Parameters:
item0- a Coord itemitem1- a Coord itemitem2- a Coord itemitem3- a Coord itemitem4- a Coord itemitem5- a Coord itemitem6- a Coord item- Returns:
- a new CoordOrderedSet that holds the given items
-
with
public static CoordOrderedSet with(Coord item0, Coord item1, Coord item2, Coord item3, Coord item4, Coord item5, Coord item6, Coord item7) Creates a new CoordOrderedSet that holds only the given items, but can be resized.- Parameters:
item0- a Coord itemitem1- a Coord itemitem2- a Coord itemitem3- a Coord itemitem4- a Coord itemitem5- a Coord itemitem6- a Coord item- Returns:
- a new CoordOrderedSet that holds the given items
-
with
Creates a new CoordOrderedSet that holds only the given items, but can be resized. This overload will only be used when an array is supplied and the type of the items requested is the component type of the array, or if varargs are used and there are 9 or more arguments.- Parameters:
varargs- a Coord varargs or Coord array; remember that varargs allocate- Returns:
- a new CoordOrderedSet that holds the given items
-
getSerializersNeeded
-