public class Maker
extends java.lang.Object
import static squidpony.Maker.*
.
Created by Tommy Ettinger on 5/19/2016.Modifier and Type | Field and Description |
---|---|
static java.lang.StringBuilder |
issueLog
Stores any information relating to non-fatal issues, such as caught and handled Exceptions that still change the
behavior of methods.
|
Constructor and Description |
---|
Maker() |
Modifier and Type | Method and Description |
---|---|
static <T> Arrangement<T> |
makeArrange(T... elements)
Makes a Arrangement (Arrange) of T given an array or vararg of T elements.
|
static <K extends java.lang.Enum<K>,V> |
makeEOM()
Makes an empty EnumOrderedMap (EOM); needs key and value types to be specified in order to work.
|
static <K extends java.lang.Enum<?>,V> |
makeEOM(K k0,
V v0,
java.lang.Object... rest)
Makes an EnumOrderedMap (EOM) with key and value types inferred from the types of k0 and v0, and considers all
remaining parameters key-value pairs, casting the Objects at positions 0, 2, 4...
|
static <T extends java.lang.Enum<T>> |
makeEOS()
Makes an empty EnumOrderedSet (EOS); needs item type to be specified in order to work.
|
static <T extends java.lang.Enum<?>> |
makeEOS(T initial,
T... elements)
Makes a EnumOrderedSet (OS) of the enum type T given at least one T element followed by an array or vararg of any
number of additional T elements.
|
static <K,V> java.util.HashMap<K,V> |
makeHM()
Makes an empty HashMap (HM); needs key and value types to be specified in order to work.
|
static <K,V> java.util.HashMap<K,V> |
makeHM(K k0,
V v0,
java.lang.Object... rest)
Makes a HashMap (HM) with key and value types inferred from the types of k0 and v0, and considers all
parameters key-value pairs, casting the Objects at positions 0, 2, 4...
|
static <T> java.util.HashSet<T> |
makeHS(T... elements)
Makes a HashSet (HS) of T given an array or vararg of T elements.
|
static <T> java.util.HashSet<T> |
makeHS(T element)
Makes a HashSet (HS) of T given a single T element.
|
static <A,B> K2<A,B> |
makeK2()
Makes an empty K2 (two-key set/bimap); needs A and B key types to be specified in order to work.
|
static <A,B> K2<A,B> |
makeK2(A a0,
B b0,
java.lang.Object... rest)
Makes a K2 (two-key set/bimap) with A and B key types inferred from the types of a0 and b0, and considers all
parameters A-B pairs, casting the Objects at positions 0, 2, 4...
|
static <A,B> K2<A,B> |
makeK2(float factor,
A a0,
B b0,
java.lang.Object... rest)
Makes a K2 (two-key set/bimap) with the given load factor (which should be between 0.1 and 0.9), A and B key
types inferred from the types of a0 and b0, and considers all parameters A-B pairs, casting the Objects at
positions 0, 2, 4...
|
static <K,V> java.util.LinkedHashMap<K,V> |
makeLHM()
Makes an empty LinkedHashMap (LHM); needs key and value types to be specified in order to work.
|
static <K,V> java.util.LinkedHashMap<K,V> |
makeLHM(K k0,
V v0,
java.lang.Object... rest)
Makes a LinkedHashMap (LHM) with key and value types inferred from the types of k0 and v0, and considers all
parameters key-value pairs, casting the Objects at positions 0, 2, 4...
|
static <T> java.util.LinkedHashSet<T> |
makeLHS(T... elements)
Makes a LinkedHashSet (LHS) of T given an array or vararg of T elements.
|
static <T> java.util.LinkedHashSet<T> |
makeLHS(T element)
Makes a LinkedHashSet (LHS) of T given a single T element.
|
static <T> java.util.ArrayList<T> |
makeList(T... elements)
Makes an ArrayList of T given an array or vararg of T elements.
|
static <T> java.util.ArrayList<T> |
makeList(T element)
Makes an ArrayList of T given a single T element; avoids creating an array for varargs as
makeList(Object[]) would do, but only allows one item. |
static <K,V> OrderedMap<K,V> |
makeOM()
Makes an empty OrderedMap (OM); needs key and value types to be specified in order to work.
|
static <K,V> OrderedMap<K,V> |
makeOM(float factor,
K k0,
V v0,
java.lang.Object... rest)
Makes an OrderedMap (OM) with the given load factor (which should be between 0.1 and 0.9), key and value types
inferred from the types of k0 and v0, and considers all remaining parameters key-value pairs, casting the Objects
at positions 0, 2, 4...
|
static <K,V> OrderedMap<K,V> |
makeOM(K k0,
V v0,
java.lang.Object... rest)
Makes an OrderedMap (OM) with key and value types inferred from the types of k0 and v0, and considers all
parameters key-value pairs, casting the Objects at positions 0, 2, 4...
|
static <T> OrderedSet<T> |
makeOS(T... elements)
Makes an OrderedSet (OS) of T given an array or vararg of T elements.
|
static <T> OrderedSet<T> |
makeOS(T element)
Makes an OrderedSet of T given a single T element; avoids creating an array for varargs as
makeOS(Object[]) would do, but only allows one item. |
static <T> UnorderedSet<T> |
makeUOS(T... elements)
Makes an UnorderedSet (UOS) of T given an array or vararg of T elements.
|
static <T> UnorderedSet<T> |
makeUOS(T element)
Makes an UnorderedSet of T given a single T element; avoids creating an array for varargs as
makeOS(Object[]) would do, but only allows one item. |
public static final java.lang.StringBuilder issueLog
public static <K,V> java.util.LinkedHashMap<K,V> makeLHM(K k0, V v0, java.lang.Object... rest)
K
- the type of keys in the returned LinkedHashMap; if not specified, will be inferred from k0V
- the type of values in the returned LinkedHashMap; if not specified, will be inferred from v0k0
- the first key; used to infer the types of other keys if generic parameters aren't specified.v0
- the first value; used to infer the types of other values if generic parameters aren't specified.rest
- an array or vararg of keys and values in pairs; should contain alternating K, V, K, V... elementspublic static <K,V> java.util.LinkedHashMap<K,V> makeLHM()
Maker.<String, Coord>makeLHM();
. Using
the new keyword is probably just as easy in this case; this method is provided for completeness relative to
makeLHM() with 2 or more parameters.K
- the type of keys in the returned LinkedHashMap; cannot be inferred and must be specifiedV
- the type of values in the returned LinkedHashMap; cannot be inferred and must be specifiedpublic static <K,V> java.util.HashMap<K,V> makeHM(K k0, V v0, java.lang.Object... rest)
K
- the type of keys in the returned HashMap; if not specified, will be inferred from k0V
- the type of values in the returned HashMap; if not specified, will be inferred from v0k0
- the first key; used to infer the types of other keys if generic parameters aren't specified.v0
- the first value; used to infer the types of other values if generic parameters aren't specified.rest
- an array or vararg of keys and values in pairs; should contain alternating K, V, K, V... elementspublic static <K,V> java.util.HashMap<K,V> makeHM()
Maker.<String, Coord>makeHM();
. Using
the new keyword is probably just as easy in this case; this method is provided for completeness relative to
makeHM() with 2 or more parameters.K
- the type of keys in the returned HashMap; cannot be inferred and must be specifiedV
- the type of values in the returned HashMap; cannot be inferred and must be specifiedpublic static <T> java.util.ArrayList<T> makeList(T... elements)
T
- just about any non-primitive typeelements
- an array or vararg of Tpublic static <T> java.util.ArrayList<T> makeList(T element)
makeList(Object[])
would do, but only allows one item.T
- just about any non-primitive, non-array type (arrays would cause confusion with the vararg method)element
- an array or vararg of Tpublic static <T> java.util.LinkedHashSet<T> makeLHS(T... elements)
T
- just about any non-primitive typeelements
- an array or vararg of Tpublic static <T> java.util.LinkedHashSet<T> makeLHS(T element)
T
- just about any non-primitive typeelement
- a single Telement
public static <T> java.util.HashSet<T> makeHS(T... elements)
T
- just about any non-primitive typeelements
- an array or vararg of Tpublic static <T> java.util.HashSet<T> makeHS(T element)
T
- just about any non-primitive typeelement
- a single Telement
public static <K,V> OrderedMap<K,V> makeOM(K k0, V v0, java.lang.Object... rest)
K
- the type of keys in the returned OrderedMap; if not specified, will be inferred from k0V
- the type of values in the returned OrderedMap; if not specified, will be inferred from v0k0
- the first key; used to infer the types of other keys if generic parameters aren't specified.v0
- the first value; used to infer the types of other values if generic parameters aren't specified.rest
- an array or vararg of keys and values in pairs; should contain alternating K, V, K, V... elementspublic static <K,V> OrderedMap<K,V> makeOM(float factor, K k0, V v0, java.lang.Object... rest)
K
- the type of keys in the returned OrderedMap; if not specified, will be inferred from k0V
- the type of values in the returned OrderedMap; if not specified, will be inferred from v0factor
- the load factor; should be between 0.1 and 0.9, and 0.75f is a safe choicek0
- the first key; used to infer the types of other keys if generic parameters aren't specified.v0
- the first value; used to infer the types of other values if generic parameters aren't specified.rest
- an array or vararg of keys and values in pairs; should contain alternating K, V, K, V... elementspublic static <K,V> OrderedMap<K,V> makeOM()
Maker.<String, Coord>makeOM()
. Using
the new keyword is probably just as easy in this case; this method is provided for completeness relative to
makeOM() with 2 or more parameters.K
- the type of keys in the returned OrderedMap; cannot be inferred and must be specifiedV
- the type of values in the returned OrderedMap; cannot be inferred and must be specifiedpublic static <T> OrderedSet<T> makeOS(T... elements)
T
- just about any non-primitive typeelements
- an array or vararg of Tpublic static <T> OrderedSet<T> makeOS(T element)
makeOS(Object[])
would do, but only allows one item.T
- just about any non-primitive, non-array type (arrays would cause confusion with the vararg method)element
- an array or vararg of Tpublic static <T> UnorderedSet<T> makeUOS(T... elements)
T
- just about any non-primitive typeelements
- an array or vararg of Tpublic static <T> UnorderedSet<T> makeUOS(T element)
makeOS(Object[])
would do, but only allows one item.T
- just about any non-primitive, non-array type (arrays would cause confusion with the vararg method)element
- an array or vararg of Tpublic static <T extends java.lang.Enum<?>> EnumOrderedSet<T> makeEOS(T initial, T... elements)
OrderedSet.getAt(int)
to get a T value at a given index, like you would with a List.T
- an enum typeinitial
- the first item to insert into the EnumOrderedSet; if initial is null, the method returns nullelements
- an array or vararg of T; allowed to be emptypublic static <T extends java.lang.Enum<T>> EnumOrderedSet<T> makeEOS()
Maker.<Radius>makeEOS()
. Using the new keyword is
probably just as easy in this case; this method is provided for completeness relative to makeEOS() with 1 or more
parameters.T
- the type of Enum keys in the returned EnumOrderedSet; cannot be inferred and must be specifiedpublic static <T> Arrangement<T> makeArrange(T... elements)
Arrangement.keyAt(int)
if you only know its index, or the int index for an item can be retrieved with
Arrangement.getInt(Object)
if you only have an item.T
- just about any non-primitive typeelements
- an array or vararg of Tpublic static <A,B> K2<A,B> makeK2(A a0, B b0, java.lang.Object... rest)
A
- a type of keys in the returned K2; if not specified, will be inferred from a0B
- a type of keys in the returned K2; if not specified, will be inferred from b0a0
- the first A key; used to infer the types of other keys if generic parameters aren't specified.b0
- the first B key; used to infer the types of other values if generic parameters aren't specified.rest
- an array or vararg of keys and values in pairs; should contain alternating A, B, A, B... elementspublic static <A,B> K2<A,B> makeK2(float factor, A a0, B b0, java.lang.Object... rest)
A
- a type of keys in the returned K2; if not specified, will be inferred from a0B
- a type of keys in the returned K2; if not specified, will be inferred from b0factor
- the load factor; should be between 0.1 and 0.9, and 0.75f is a safe choicea0
- the first A key; used to infer the types of other keys if generic parameters aren't specified.b0
- the first B key; used to infer the types of other values if generic parameters aren't specified.rest
- an array or vararg of keys and values in pairs; should contain alternating A, B, A, B... elementspublic static <A,B> K2<A,B> makeK2()
Maker.<String, Coord>makeK2();
. Using
the new keyword is probably just as easy in this case; this method is provided for completeness relative to
makeK2() with 2 or more parameters.A
- the type of "A" keys in the returned K2; cannot be inferred and must be specifiedB
- the type of "B" keys in the returned K2; cannot be inferred and must be specifiedpublic static <K extends java.lang.Enum<?>,V> EnumOrderedMap<K,V> makeEOM(K k0, V v0, java.lang.Object... rest)
OrderedMap.keyAt(int)
or
OrderedMap.getAt(int)
to get a key or value at a given index, like you would with a List.K
- the type of Enum keys in the returned EnumOrderedMap; if not specified, will be inferred from k0V
- the type of values in the returned EnumOrderedMap; if not specified, will be inferred from v0k0
- the first key, which must be an Enum; used to infer the types of other keys if generic parameters aren't specified.v0
- the first value; used to infer the types of other values if generic parameters aren't specified.rest
- an array or vararg of keys and values in pairs; should contain alternating K, V, K, V... elementspublic static <K extends java.lang.Enum<K>,V> EnumOrderedMap<K,V> makeEOM()
Maker.<Radius, Coord>makeEOM()
. Using
the new keyword is probably just as easy in this case; this method is provided for completeness relative to
makeEOM() with 2 or more parameters.K
- the type of Enum keys in the returned EnumOrderedMap; cannot be inferred and must be specifiedV
- the type of values in the returned EnumOrderedMap; cannot be inferred and must be specifiedCopyright © Eben Howard 2012–2022. All rights reserved.