Package com.google.common.collect
Class Platform
java.lang.Object
com.google.common.collect.Platform
Methods factored out so that they can be emulated differently in GWT.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static <T> T[]
Equivalent to Arrays.copyOfRange(source, from, to, arrayOfType.getClass()).(package private) static <T> T[]
newArray
(T[] reference, int length) Returns a new array of the given length with the same type as a reference array.(package private) static <E> Set
<E> Returns the platform preferred implementation of a thread-safe hash set.(package private) static <K,
V> Map <K, V> newHashMapWithExpectedSize
(int expectedSize) Returns the platform preferred implementation of a map based on a hash table.(package private) static <E> Set
<E> newHashSetWithExpectedSize
(int expectedSize) Returns the platform preferred implementation of a set based on a hash table.(package private) static <K,
V> Map <K, V> newLinkedHashMapWithExpectedSize
(int expectedSize) Returns the platform preferred implementation of an insertion ordered map based on a hash table.(package private) static <E> Set
<E> newLinkedHashSetWithExpectedSize
(int expectedSize) Returns the platform preferred implementation of an insertion ordered set based on a hash table.(package private) static <E> Set
<E> Returns the platform preferred set implementation that preserves insertion order when used only for insertions.(package private) static <K,
V> Map <K, V> Returns the platform preferred map implementation that preserves insertion order when used only for insertions.(package private) static <K,
V> Map <K, V> preservesInsertionOrderOnPutsMapWithExpectedSize
(int expectedSize) Returns the platform preferred map implementation that preserves insertion order when used only for insertions, with a hint for how many entries to expect.(package private) static int
reduceExponentIfGwt
(int exponent) (package private) static int
reduceIterationsIfGwt
(int iterations) (package private) static MapMaker
tryWeakKeys
(MapMaker mapMaker) Configures the given map maker to use weak keys, if possible; does nothing otherwise (i.e., in GWT).
-
Constructor Details
-
Platform
private Platform()
-
-
Method Details
-
newHashMapWithExpectedSize
Returns the platform preferred implementation of a map based on a hash table. -
newLinkedHashMapWithExpectedSize
Returns the platform preferred implementation of an insertion ordered map based on a hash table. -
newHashSetWithExpectedSize
Returns the platform preferred implementation of a set based on a hash table. -
newConcurrentHashSet
Returns the platform preferred implementation of a thread-safe hash set. -
newLinkedHashSetWithExpectedSize
Returns the platform preferred implementation of an insertion ordered set based on a hash table. -
preservesInsertionOrderOnPutsMap
Returns the platform preferred map implementation that preserves insertion order when used only for insertions. -
preservesInsertionOrderOnPutsMapWithExpectedSize
Returns the platform preferred map implementation that preserves insertion order when used only for insertions, with a hint for how many entries to expect. -
preservesInsertionOrderOnAddsSet
Returns the platform preferred set implementation that preserves insertion order when used only for insertions. -
newArray
static <T> T[] newArray(T[] reference, int length) Returns a new array of the given length with the same type as a reference array.- Parameters:
reference
- any array of the desired typelength
- the length of the new array
-
copy
Equivalent to Arrays.copyOfRange(source, from, to, arrayOfType.getClass()). -
tryWeakKeys
Configures the given map maker to use weak keys, if possible; does nothing otherwise (i.e., in GWT). This is sometimes acceptable, when only server-side code could generate enough volume that reclamation becomes important. -
getDeclaringClassOrObjectForJ2cl
-
reduceIterationsIfGwt
static int reduceIterationsIfGwt(int iterations) -
reduceExponentIfGwt
static int reduceExponentIfGwt(int exponent)
-