Package com.github.tommyettinger.ds
Enum Class OrderType
- All Implemented Interfaces:
Serializable,Comparable<OrderType>,Constable
Used to determine what class Ordered objects will use for their
Each ordering type has different advantages and disadvantages. Each variety offers constant-time
The reason to use
If a type of ordering isn't available for a given item type, this should default to
Ordered.order() implementation. This is
always a subclass of the type returned by order(), such as ObjectList for Ordered or LongList for
Ordered.OfLong. ObjectList only has ObjectBag as its subclass here, but the primitive lists
such as IntList have IntBag and IntDeque as subclasses that may be used.
Each ordering type has different advantages and disadvantages. Each variety offers constant-time
ArrayList.get(int) performance, and amortized constant-time ArrayList.add(Object) to the end.
DEQUE has slower get(int) performance in practice than the others, but not worse algorithmic complexity.
Adding to the beginning of the iteration order is constant-time for DEQUE, but linear-time for
LIST and BAG. Both LIST and DEQUE preserve insertion order, but BAG is
permitted to rearrange items whenever an item is removed. Removal performs very differently. with LIST
removing in constant time only for the last item in the iteration order, or linear time for any other item.
DEQUE removes items at the start or end of the order in constant-time, and linear time for other positions.
BAG has constant-time removal from any position by swapping the item at the end into the place of the
removed item. All types permit sorting, but BAG only holds its sorted order until an item is removed. All
types have faster iteration than an unordered set or map.
The reason to use
LIST is to preserve iteration order and allow fast get() by index. DEQUE also
preserves iteration order and makes insertion or removal at either end of the order faster. BAG allows sets
and maps to keep or improve on the complexity of an unordered set or map for all operations, while speeding up
iteration as long as the order doesn't need to be kept between iterations over the type/.
If a type of ordering isn't available for a given item type, this should default to
LIST.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Method Summary
-
Enum Constant Details
-
LIST
-
BAG
-
DEQUE
Theorder()method will return a deque (which is also always a list here), such asLongDequeorIntDeque. This will not be valid for Object-based types, becauseObjectDequeis not a subclass ofObjectList.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-