Class EnumFloatOrderedMap

java.lang.Object
com.github.tommyettinger.ds.EnumFloatMap
com.github.tommyettinger.ds.EnumFloatOrderedMap
All Implemented Interfaces:
Arrangeable, Ordered<Enum<?>>, Iterable<EnumFloatMap.Entry>

public class EnumFloatOrderedMap extends EnumFloatMap implements Ordered<Enum<?>>
An insertion-ordered map where the keys are Enums and values are primitive floats. Null keys are not allowed. Unlike EnumMap, this does not require a Class at construction time, which can be useful for serialization purposes. No allocation is done unless this is changing its table size and/or key universe.
This class never actually hashes keys in its primary operations (get(), put(), remove(), containsKey(), etc.), since it can rely on keys having an Enum type, and so having Enum.ordinal() available. The ordinal allows constant-time access to a guaranteed-unique int that will always be non-negative and less than the size of the key universe. The table of possible values always starts sized to fit exactly as many values as there are keys in the key universe.
The key universe is an important concept here; it is simply an array of all possible Enum values the EnumFloatOrderedMap can use as keys, in the specific order they are declared. You almost always get a key universe by calling MyEnum.values(), but you can also use Class.getEnumConstants() for an Enum class. You can and generally should reuse key universes in order to avoid allocations and/or save memory; the constructor EnumFloatOrderedMap(Enum[]) (with no values given) creates an empty EnumFloatOrderedMap with a given key universe. If you need to use the zero-argument constructor, you can, and the key universe will be obtained from the first key placed into the EnumFloatOrderedMap. You can also set the key universe with clearToUniverse(Enum[]), in the process of clearing the map.
This class tries to be as compatible as possible with EnumMap while using primitive keys, though this expands on that where possible.
  • Field Details

  • Constructor Details

    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(OrderType type)
      Constructor that only specifies an OrderType; using this will postpone creating the key universe and allocating the value table until put(java.lang.Enum<?>, float) is first called (potentially indirectly). You can also use clearToUniverse(java.lang.Enum<?>[]) to set the key universe and value table.
      Parameters:
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Enum<?>[] universe, OrderType type)
      Initializes this map so that it has exactly enough capacity as needed to contain each Enum constant defined in universe, assuming universe stores every possible constant in one Enum type. This map will start empty. You almost always obtain universe from calling values() on an Enum type, and you can share one reference to one Enum array across many EnumFloatOrderedMap instances if you don't modify the shared array. Sharing the same universe helps save some memory if you have (very) many EnumFloatOrderedMap instances.
      Parameters:
      universe - almost always, the result of calling values() on an Enum type; used directly, not copied
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Class<? extends Enum<?>> universeClass, OrderType type)
      Initializes this map so that it has exactly enough capacity as needed to contain each Enum constant defined by the Class universeClass, assuming universeClass is non-null. This simply calls EnumFloatOrderedMap(Enum[]) for convenience. Note that this constructor allocates a new array of Enum constants each time it is called, where if you use EnumFloatOrderedMap(Enum[]), you can reuse an unmodified array to reduce allocations.
      Parameters:
      universeClass - the Class of an Enum type that defines the universe of valid Enum items this can hold
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(EnumFloatOrderedMap map, OrderType type)
      Creates a new map identical to the specified EnumFloatOrderedMap. This will share a key universe with the given EnumFloatOrderedMap, if non-null. This overload allows specifying the OrderType independently of the one used in map.
      Parameters:
      map - an EnumFloatOrderedMap to copy
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Enum<?>[] keys, float[] values, OrderType type)
      Given two side-by-side arrays, one of Enum keys, one of float values, this constructs a map and inserts each pair of key and value into it. If keys and values have different lengths, this only uses the length of the smaller array.
      Parameters:
      keys - an array of Enum keys
      values - an array of float values
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Collection<? extends Enum<?>> keys, PrimitiveCollection.OfFloat values, OrderType type)
      Given two side-by-side collections, one of Enum keys, one of float values, this constructs a map and inserts each pair of key and value into it. If keys and values have different lengths, this only uses the length of the smaller collection.
      Parameters:
      keys - a Collection of Enum keys
      values - a PrimitiveCollection of float values
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(EnumFloatOrderedMap other, int offset, int count, OrderType type)
      Creates a new map by copying count items from the given EnumFloatOrderedMap, starting at offset in that Map, into this. This overload allows specifying the OrderType independently of the one used in other.
      Parameters:
      other - another EnumFloatOrderedMap
      offset - the first index in other's ordering to draw an item from
      count - how many items to copy from other
      type - either OrderType.BAG to use unreliable ordering with faster deletion, or anything else to use a list type that takes longer to delete but maintains insertion order reliably
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap()
      Empty constructor; using this will postpone creating the key universe and allocating the value table until put(java.lang.Enum<?>, float) is first called (potentially indirectly). You can also use clearToUniverse(java.lang.Enum<?>[]) to set the key universe and value table.
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Enum<?>[] universe)
      Initializes this map so that it has exactly enough capacity as needed to contain each Enum constant defined in universe, assuming universe stores every possible constant in one Enum type. This map will start empty. You almost always obtain universe from calling values() on an Enum type, and you can share one reference to one Enum array across many EnumFloatOrderedMap instances if you don't modify the shared array. Sharing the same universe helps save some memory if you have (very) many EnumFloatOrderedMap instances.
      Parameters:
      universe - almost always, the result of calling values() on an Enum type; used directly, not copied
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Class<? extends Enum<?>> universeClass)
      Initializes this map so that it has exactly enough capacity as needed to contain each Enum constant defined by the Class universeClass, assuming universeClass is non-null. This simply calls EnumFloatOrderedMap(Enum[]) for convenience. Note that this constructor allocates a new array of Enum constants each time it is called, where if you use EnumFloatOrderedMap(Enum[]), you can reuse an unmodified array to reduce allocations.
      Parameters:
      universeClass - the Class of an Enum type that defines the universe of valid Enum items this can hold
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(EnumFloatOrderedMap map)
      Creates a new map identical to the specified EnumFloatOrderedMap. This will share a key universe with the given EnumFloatOrderedMap, if non-null. This overload uses the OrderType of the given map.
      Parameters:
      map - an EnumFloatOrderedMap to copy
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Enum<?>[] keys, float[] values)
      Given two side-by-side arrays, one of Enum keys, one of float values, this constructs a map and inserts each pair of key and value into it. If keys and values have different lengths, this only uses the length of the smaller array.
      Parameters:
      keys - an array of Enum keys
      values - an array of float values
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(Collection<? extends Enum<?>> keys, PrimitiveCollection.OfFloat values)
      Given two side-by-side collections, one of Enum keys, one of float values, this constructs a map and inserts each pair of key and value into it. If keys and values have different lengths, this only uses the length of the smaller collection.
      Parameters:
      keys - a Collection of Enum keys
      values - a PrimitiveCollection of float values
    • EnumFloatOrderedMap

      public EnumFloatOrderedMap(EnumFloatOrderedMap other, int offset, int count)
      Creates a new map by copying count items from the given EnumFloatOrderedMap, starting at offset in that Map, into this. This overload uses the OrderType of the given map.
      Parameters:
      other - another EnumFloatOrderedMap
      offset - the first index in other's ordering to draw an item from
      count - how many items to copy from other
  • Method Details

    • putAll

      public void putAll(Collection<? extends Enum<?>> keys, PrimitiveCollection.OfFloat values)
      Given two side-by-side collections, one of Enum keys, one of float values, this inserts each pair of key and value into this map with put().
      Overrides:
      putAll in class EnumFloatMap
      Parameters:
      keys - a Collection of Enum keys
      values - a PrimitiveCollection of float values
    • put

      public float put(Enum<?> key, float value)
      Returns the old value associated with the specified key, or this map's EnumFloatMap.defaultValue if there was no prior value. If this EnumFloatOrderedMap does not yet have a key universe and/or value table, this gets the key universe from key and uses it from now on for this EnumFloatOrderedMap.
      Overrides:
      put in class EnumFloatMap
      Parameters:
      key - the Enum key to try to place into this EnumFloatOrderedMap
      value - the float value to associate with key
      Returns:
      the previous value associated with key, or EnumFloatMap.getDefaultValue() if the given key was not present
    • put

      public float put(Enum<?> key, float value, int index)
      Puts the given key and value into this map at the given index in its order. If the key is already present at a different index, it is moved to the given index and its value is set to the given value.
      Parameters:
      key - an Enum key; must not be null
      value - a float value
      index - the index in the order to place the given key and value; must be non-negative and less than EnumFloatMap.size()
      Returns:
      the previous value associated with key, if there was one, or EnumFloatMap.defaultValue otherwise
    • putOrDefault

      public float putOrDefault(Enum<?> key, float value, float defaultValue)
      Description copied from class: EnumFloatMap
      Acts like EnumFloatMap.put(Enum, float), but uses the specified defaultValue instead of the default value for this EnumFloatMap.
      Overrides:
      putOrDefault in class EnumFloatMap
      Parameters:
      key - the Enum key to try to place into this EnumFloatMap
      value - the float value to associate with key
      defaultValue - the float value to return if key was not already present
      Returns:
      the previous value associated with key, or the given defaultValue if the given key was not present
    • putAll

      public void putAll(EnumFloatOrderedMap map)
      Puts every key-value pair in the given map into this, with the values from the given map overwriting the previous values if two keys are identical. This will put keys in the order of the given map.
      Parameters:
      map - a map with compatible key and value types; will not be modified
    • putAll

      public void putAll(EnumFloatOrderedMap other, int offset, int count)
      Adds up to count entries, starting from offset, in the map other to this set, inserting at the end of the iteration order.
      Parameters:
      other - a non-null ordered map with the same type and compatible generic types
      offset - the first index in other to use
      count - how many indices in other to use
    • putAll

      public void putAll(int insertionIndex, EnumFloatOrderedMap other, int offset, int count)
      Adds up to count entries, starting from offset, in the map other to this set, inserting starting at insertionIndex in the iteration order.
      Parameters:
      insertionIndex - where to insert into the iteration order
      other - a non-null ordered map with the same type and compatible generic types
      offset - the first index in other to use
      count - how many indices in other to use
    • remove

      public float remove(Object key)
      Overrides:
      remove in class EnumFloatMap
    • removeAt

      public float removeAt(int index)
      Removes the entry at the given index in the order, returning the value of that entry.
      Parameters:
      index - the index of the entry to remove; must be at least 0 and less than EnumFloatMap.size()
      Returns:
      the value of the removed entry
    • removeRange

      public void removeRange(int start, int end)
      Removes the items between the specified start index, inclusive, and end index, exclusive. Note that this takes different arguments than some other range-related methods; this needs a start index and an end index, rather than a count of items. This matches the behavior in the JDK collections.
      Specified by:
      removeRange in interface Ordered<Enum<?>>
      Parameters:
      start - the first index to remove, inclusive
      end - the last index (after what should be removed), exclusive
    • truncate

      public void truncate(int newSize)
      Reduces the size of the map to the specified size. If the map is already smaller than the specified size, no action is taken.
      Parameters:
      newSize - the target size to try to reach by removing items, if smaller than the current size
    • putAll

      public void putAll(ObjectFloatOrderedMap<Enum<?>> map)
      Copies all the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
      Note that putAll(EnumFloatOrderedMap) is more specific and can be more efficient by using the internal details of this class.
      Parameters:
      map - mappings to be stored in this map
      Throws:
      UnsupportedOperationException - if the putAll operation is not supported by this map
      ClassCastException - if the class of a key or value in the specified map prevents it from being stored in this map
      NullPointerException - if the specified map is null, or if this map does not permit null keys or values, and the specified map contains null keys or values
      IllegalArgumentException - if some property of a key or value in the specified map prevents it from being stored in this map
    • getAndIncrement

      public float getAndIncrement(Enum<?> key, float defaultValue, float increment)
      Description copied from class: EnumFloatMap
      Returns the key's current value and increments the stored value. If the key is not in the map, defaultValue + increment is put into the map and defaultValue is returned.
      Overrides:
      getAndIncrement in class EnumFloatMap
    • alter

      public boolean alter(Enum<?> before, Enum<?> after)
      Changes the key before to after without changing its position in the order or its value. Returns true if after has been added to the EnumFloatOrderedMap and before has been removed; returns false if after is already present or before is not present. If you are iterating over an EnumFloatOrderedMap and have an index, you should prefer alterAt(int, Enum), which doesn't need to search for an index like this does and so can be faster.
      Parameters:
      before - a key that must be present for this to succeed
      after - a key that must not be in this map for this to succeed
      Returns:
      true if before was removed and after was added, false otherwise
    • alterAt

      public boolean alterAt(int index, Enum<?> after)
      Changes the key at the given index in the order to after, without changing the ordering of other entries or any values. If after is already present, this returns false; it will also return false if index is invalid for the size of this map. Otherwise, it returns true. Unlike alter(Enum, Enum), this operates in constant time.
      Parameters:
      index - the index in the order of the key to change; must be non-negative and less than EnumFloatMap.size()
      after - the key that will replace the contents at index; this key must not be present for this to succeed
      Returns:
      true if after successfully replaced the key at index, false otherwise
    • setAt

      public float setAt(int index, float v)
      Changes the value at a specified index in the iteration order to v, without changing keys at all. If index isn't currently a valid index in the iteration order, this returns null. Otherwise, it returns the value that was previously held at index, which may also be null.
      Parameters:
      v - the new float value to assign
      index - the index in the iteration order to set v at
      Returns:
      the previous value held at index in the iteration order, which may be null if the value was null or if index was invalid
    • getAt

      public float getAt(int index)
      Gets the float value at the given index in the insertion order. The index should be between 0 (inclusive) and EnumFloatMap.size() (exclusive).
      Parameters:
      index - an index in the insertion order, between 0 (inclusive) and EnumFloatMap.size() (exclusive)
      Returns:
      the value at the given index
    • keyAt

      public Enum<?> keyAt(int index)
      Gets the K key at the given index in the insertion order. The index should be between 0 (inclusive) and EnumFloatMap.size() (exclusive).
      Parameters:
      index - an index in the insertion order, between 0 (inclusive) and EnumFloatMap.size() (exclusive)
      Returns:
      the key at the given index
    • clear

      public void clear()
      Description copied from class: EnumFloatMap
      Removes all the elements from this map. The map will be empty after this call returns. This does not change the universe of possible Enum items this can hold.
      Overrides:
      clear in class EnumFloatMap
    • clearToUniverse

      public void clearToUniverse(Enum<?>[] universe)
      Description copied from class: EnumFloatMap
      Removes all the elements from this map and can reset the universe of possible Enum items this can hold. The map will be empty after this call returns. This changes the universe of possible Enum items this can hold to match universe. If universe is null, this resets this map to the state it would have after EnumFloatMap() was called. If the table this would need is the same size as or smaller than the current table (such as if universe is the same as the universe here), this will not allocate, but will still clear any items this holds and will set the universe to the given one. Otherwise, this allocates and uses a new table of a larger size, with nothing in it, and uses the given universe. This always uses universe directly, without copying.
      This can be useful to allow an EnumFloatMap that was created with EnumFloatMap() to share a universe with other EnumFloatMaps.
      Overrides:
      clearToUniverse in class EnumFloatMap
      Parameters:
      universe - the universe of possible Enum items this can hold; almost always produced by values() on an Enum
    • clearToUniverse

      public void clearToUniverse(Class<? extends Enum<?>> universe)
      Description copied from class: EnumFloatMap
      Removes all the elements from this map and can reset the universe of possible Enum items this can hold. The map will be empty after this call returns. This changes the universe of possible Enum items this can hold to match the Enum constants in universe. If universe is null, this resets this map to the state it would have after EnumFloatMap() was called. If the table this would need is the same size as or smaller than the current table (such as if universe is the same as the universe here), this will not allocate, but will still clear any items this holds and will set the universe to the given one. Otherwise, this allocates and uses a new table of a larger size, with nothing in it, and uses the given universe. This calls Class.getEnumConstants() if universe is non-null, which allocates a new array.
      You may want to prefer calling EnumFloatMap.clearToUniverse(Enum[]) (the overload that takes an array), because it can be used to share one universe array between many EnumFloatMap instances. This overload, given a Class, has to call Class.getEnumConstants() and thus allocate a new array each time this is called.
      Overrides:
      clearToUniverse in class EnumFloatMap
      Parameters:
      universe - the Class of an Enum type that stores the universe of possible Enum items this can hold
    • order

      public ObjectList<Enum<?>> order()
      Gets the ObjectList of keys in the order this class will iterate through them. Returns a direct reference to the same ObjectList this uses, so changes to the returned list will also change the iteration order here.
      Specified by:
      order in interface Ordered<Enum<?>>
      Returns:
      the ObjectList of keys, in iteration order (usually insertion-order), that this uses
    • sort

      public void sort()
      Sorts this EnumFloatOrderedMap in-place by the keys' natural ordering.
    • sort

      public void sort(Comparator<? super Enum<?>> comp)
      Sorts this EnumFloatOrderedMap in-place by the given Comparator used on the keys. If comp is null, then this will sort by the natural ordering of the keys.
      Specified by:
      sort in interface Ordered<Enum<?>>
      Parameters:
      comp - a Comparator that can compare two Enum keys, or null to use the keys' natural ordering
    • sortByValue

      public void sortByValue(FloatComparator comp)
      Sorts this EnumFloatOrderedMap in-place by the given FloatComparator used on the values. comp must not be null, and must be able to compare float values. You can use FloatComparators.NATURAL_COMPARATOR to do what sort() does (just sorting values in this case instead of keys); there is also a reversed comparator available, FloatComparators.OPPOSITE_COMPARATOR.
      Parameters:
      comp - a non-null FloatComparator
    • keySet

      public EnumFloatMap.Keys keySet()
      Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

      Note that the same Collection instance is returned each time this method is called. Use the OrderedMapKeys(EnumFloatOrderedMap) constructor for nested or multithreaded iteration.

      Overrides:
      keySet in class EnumFloatMap
      Returns:
      a set view of the keys contained in this map
    • values

      public EnumFloatMap.Values values()
      Returns a PrimitiveCollection for the values in the map. Remove is supported by the PrimitiveCollection's iterator.

      Note that the same PrimitiveCollection.OfFloat instance is returned each time this method is called. Use the OrderedMapValues(EnumFloatOrderedMap) constructor for nested or multithreaded iteration.

      Overrides:
      values in class EnumFloatMap
      Returns:
      a PrimitiveCollection.OfFloat of the float values
    • entrySet

      public EnumFloatMap.Entries entrySet()
      Returns a Set of Map.Entry, containing the entries in the map. Remove is supported by the Set's iterator.

      Note that the same iterator instance is returned each time this method is called. Use the OrderedMapEntries(EnumFloatOrderedMap) constructor for nested or multithreaded iteration.

      Overrides:
      entrySet in class EnumFloatMap
      Returns:
      a Set of Map.Entry key-value pairs
    • iterator

      public EnumFloatMap.EntryIterator iterator()
      Reuses the iterator of the reused EnumFloatMap.Entries produced by entrySet(); does not permit nested iteration. Iterate over OrderedMapEntries(EnumFloatOrderedMap) if you need nested or multithreaded iteration. You can remove an Entry from this EnumFloatOrderedMap using this Iterator.
      Specified by:
      iterator in interface Iterable<EnumFloatMap.Entry>
      Overrides:
      iterator in class EnumFloatMap
      Returns:
      an Iterator over key-value pairs as EnumFloatMap.Entry values
    • appendTo

      public StringBuilder appendTo(StringBuilder sb, String entrySeparator, String keyValueSeparator, boolean braces, Appender<Enum<?>> keyAppender, FloatAppender valueAppender)
      Appends to a StringBuilder from the contents of this EnumFloatOrderedMap, but uses the given Appender and FloatAppender to convert each key and each value to a customizable representation and append them to a StringBuilder. These functions are often method references to methods in Base, such as Base.appendUnsigned(CharSequence, float). To use the default toString representation, you can use Appender::append as an appender, or to use the readable Enum Enum.name(), use Appender.ENUM_NAME_APPENDER. Use FloatAppender.DEFAULT or FloatAppender.READABLE for human-readable or source-code-readable results, respectively.
      Overrides:
      appendTo in class EnumFloatMap
      Parameters:
      sb - a StringBuilder that this can append to
      entrySeparator - how to separate entries, such as ", "
      keyValueSeparator - how to separate each key from its value, such as "=" or ":"
      braces - true to wrap the output in curly braces, or false to omit them
      keyAppender - a function that takes a StringBuilder and a K, and returns the modified StringBuilder
      valueAppender - a function that takes a StringBuilder and a float, and returns the modified StringBuilder
      Returns:
      sb, with the appended keys and values of this map
    • with

      public static EnumFloatOrderedMap with()
      Constructs an empty map. 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 map containing nothing
    • with

      public static EnumFloatOrderedMap with(Enum<?> key0, Number value0)
      Constructs a single-entry map given one key and one value. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Like the more-argument with(), this will convert its Number value to a primitive float, regardless of which Number type was used.
      Parameters:
      key0 - the first and only Enum key
      value0 - the first and only value; will be converted to primitive float
      Returns:
      a new map containing just the entry mapping key0 to value0
    • with

      public static EnumFloatOrderedMap with(Enum<?> key0, Number value0, Enum<?> key1, Number value1)
      Constructs a map given alternating keys and values. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Like the more-argument with(), this will convert its Number values to primitive floats, regardless of which Number type was used.
      Parameters:
      key0 - an Enum key
      value0 - a Number for a value; will be converted to primitive float
      key1 - an Enum key
      value1 - a Number for a value; will be converted to primitive float
      Returns:
      a new map containing the given key-value pairs
    • with

      public static EnumFloatOrderedMap with(Enum<?> key0, Number value0, Enum<?> key1, Number value1, Enum<?> key2, Number value2)
      Constructs a map given alternating keys and values. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Like the more-argument with(), this will convert its Number values to primitive floats, regardless of which Number type was used.
      Parameters:
      key0 - an Enum key
      value0 - a Number for a value; will be converted to primitive float
      key1 - an Enum key
      value1 - a Number for a value; will be converted to primitive float
      key2 - an Enum key
      value2 - a Number for a value; will be converted to primitive float
      Returns:
      a new map containing the given key-value pairs
    • with

      public static EnumFloatOrderedMap with(Enum<?> key0, Number value0, Enum<?> key1, Number value1, Enum<?> key2, Number value2, Enum<?> key3, Number value3)
      Constructs a map given alternating keys and values. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Like the more-argument with(), this will convert its Number values to primitive floats, regardless of which Number type was used.
      Parameters:
      key0 - an Enum key
      value0 - a Number for a value; will be converted to primitive float
      key1 - an Enum key
      value1 - a Number for a value; will be converted to primitive float
      key2 - an Enum key
      value2 - a Number for a value; will be converted to primitive float
      key3 - an Enum key
      value3 - a Number for a value; will be converted to primitive float
      Returns:
      a new map containing the given key-value pairs
    • with

      public static EnumFloatOrderedMap with(Enum<?> key0, Number value0, Object... rest)
      Constructs a map given alternating keys and values. This can be useful in some code-generation scenarios, or when you want to make a map conveniently by-hand and have it populated at the start. You can also use EnumFloatOrderedMap(Enum[], float[]), which takes all keys and then all values. This needs all keys to be Enum constants. All values must be some type of boxed Number, such as Integer or Double, and will be converted to primitive floats. Any keys that don't have Enum as their type or values that aren't Numbers have that entry skipped.
      Parameters:
      key0 - the first Enum key
      value0 - the first value; will be converted to primitive float
      rest - an array or varargs of alternating Enum, Number, Enum, Number... elements
      Returns:
      a new map containing the given keys and values
    • parse

      public static EnumFloatOrderedMap parse(String str, String entrySeparator, String keyValueSeparator, PartialParser<Enum<?>> keyParser)
      Creates a new map by parsing all of str with the given PartialParser for keys, with entries separated by entrySeparator, such as ", " and the keys separated from values by keyValueSeparator, such as "=".
      The keyParser is often produced by PartialParser.enumParser(ObjToObjFunction).
      Parameters:
      str - a String containing parseable text
      entrySeparator - the String separating every key-value pair
      keyValueSeparator - the String separating every key from its corresponding value
      keyParser - a PartialParser that returns an Enum key from a section of str
    • parse

      public static EnumFloatOrderedMap parse(String str, String entrySeparator, String keyValueSeparator, PartialParser<Enum<?>> keyParser, boolean brackets)
      Creates a new map by parsing all of str (or if brackets is true, all but the first and last chars) with the given PartialParser for keys, with entries separated by entrySeparator, such as ", " and the keys separated from values by keyValueSeparator, such as "=".
      The keyParser is often produced by PartialParser.enumParser(ObjToObjFunction).
      Parameters:
      str - a String containing parseable text
      entrySeparator - the String separating every key-value pair
      keyValueSeparator - the String separating every key from its corresponding value
      keyParser - a PartialParser that returns an Enum key from a section of str
      brackets - if true, the first and last chars in str will be ignored
    • parse

      public static EnumFloatOrderedMap parse(String str, String entrySeparator, String keyValueSeparator, PartialParser<Enum<?>> keyParser, int offset, int length)
      Creates a new map by parsing the given subrange of str with the given PartialParser for keys, with entries separated by entrySeparator, such as ", " and the keys separated from values by keyValueSeparator, such as "=".
      The keyParser is often produced by PartialParser.enumParser(ObjToObjFunction).
      Parameters:
      str - a String containing parseable text
      entrySeparator - the String separating every key-value pair
      keyValueSeparator - the String separating every key from its corresponding value
      keyParser - a PartialParser that returns an Enum key from a section of str
      offset - the first position to read parseable text from in str
      length - how many chars to read; -1 is treated as maximum length
    • withPrimitive

      public static EnumFloatOrderedMap withPrimitive()
      Constructs an empty map. 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 map containing nothing
    • withPrimitive

      public static EnumFloatOrderedMap withPrimitive(Enum<?> key0, float value0)
      Constructs a single-entry map given one key and one value. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Unlike with(), this takes unboxed float as its value type, and will not box it.
      Parameters:
      key0 - an Enum for a key
      value0 - a float for a value
      Returns:
      a new map containing just the entry mapping key0 to value0
    • withPrimitive

      public static EnumFloatOrderedMap withPrimitive(Enum<?> key0, float value0, Enum<?> key1, float value1)
      Constructs a map given alternating keys and values. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Unlike with(), this takes unboxed float as its value type, and will not box it.
      Parameters:
      key0 - an Enum key
      value0 - a float for a value
      key1 - an Enum key
      value1 - a float for a value
      Returns:
      a new map containing the given key-value pairs
    • withPrimitive

      public static EnumFloatOrderedMap withPrimitive(Enum<?> key0, float value0, Enum<?> key1, float value1, Enum<?> key2, float value2)
      Constructs a map given alternating keys and values. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Unlike with(), this takes unboxed float as its value type, and will not box it.
      Parameters:
      key0 - an Enum key
      value0 - a float for a value
      key1 - an Enum key
      value1 - a float for a value
      key2 - an Enum key
      value2 - a float for a value
      Returns:
      a new map containing the given key-value pairs
    • withPrimitive

      public static EnumFloatOrderedMap withPrimitive(Enum<?> key0, float value0, Enum<?> key1, float value1, Enum<?> key2, float value2, Enum<?> key3, float value3)
      Constructs a map given alternating keys and values. This is mostly useful as an optimization for with(Enum, Number, Object...) when there's no "rest" of the keys or values. Unlike with(), this takes unboxed float as its value type, and will not box it.
      Parameters:
      key0 - an Enum key
      value0 - a float for a value
      key1 - an Enum key
      value1 - a float for a value
      key2 - an Enum key
      value2 - a float for a value
      key3 - an Enum key
      value3 - a float for a value
      Returns:
      a new map containing the given key-value pairs
    • of

      public static EnumFloatOrderedMap of()
      Constructs an empty map. 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. This is an alias for with().
      Returns:
      a new map containing nothing
    • of

      public static EnumFloatOrderedMap of(Enum<?> key0, Number value0, Object... rest)
      Constructs a map given alternating keys and values. This can be useful in some code-generation scenarios, or when you want to make a map conveniently by-hand and have it populated at the start. You can also use EnumFloatOrderedMap(Enum[], float[]), which takes all keys and then all values. This needs all keys to be Enum constants. All values must be some type of boxed Number, such as Integer or Double, and will be converted to primitive floats. Any keys that don't have Enum as their type or values that aren't Numbers have that entry skipped. This is an alias for with(Enum, Number, Object...).
      Parameters:
      key0 - the first Enum key
      value0 - the first value; will be converted to primitive float
      rest - an array or varargs of alternating Enum, Number, Enum, Number... elements
      Returns:
      a new map containing the given keys and values