org.javimmutable.collections.util
Class JImmutables
java.lang.Object
org.javimmutable.collections.util.JImmutables
public final class JImmutables
- extends Object
This class contains static factory methods to create instances of each of the collection interfaces.
Overloaded variants are provided for each to pre-populate the created collection with existing values.
Where possible the empty collection methods return a common singleton instance to save memory. The
factory methods always return the fastest implementation of each interface (i.e. hash when sort not
required, trie when random access not required, etc).
Method Summary |
static
|
array()
Creates an empty sparse array that supports any integer (positive or negative) as an index. |
static
|
array(Cursor<JImmutableMap.Entry<Integer,T>> source)
Creates a sparse array containing all of the values from source that supports any integer
(positive or negative) as an index. |
static
|
array(Indexed<? extends T> source)
Creates a sparse array containing all of the values from source that supports any integer
(positive or negative) as an index. |
static
|
array(Indexed<? extends T> source,
int offset,
int limit)
Creates a sparse array containing all of the values in the specified range from source that
supports any integer (positive or negative) as an index. |
static
|
array(List<? extends T> source)
Creates a sparse array containing all of the values from source that supports any integer
(positive or negative) as an index. |
static
|
array(T... source)
Creates an empty sparse array that supports any integer (positive or negative) as an index. |
static
|
insertOrderListMap()
Creates a list map with keys sorted by order they are inserted. |
static
|
insertOrderMap()
Constructs an empty map whose cursors traverse elements in the same order that they
were originally added to the map. |
static
|
insertOrderMap(JImmutableMap<K,V> source)
Constructs a map whose cursors traverse elements in the same order that they
were originally added to the map. |
static
|
insertOrderMap(Map<K,V> source)
Constructs a map whose cursors traverse elements in the same order that they
were originally added to the map. |
static
|
insertOrderSet()
Constructs an empty set that sorts values based on the order they were originally added to the set. |
static
|
insertOrderSet(Collection<? extends T> source)
Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set. |
static
|
insertOrderSet(Cursor<? extends T> source)
Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set. |
static
|
insertOrderSet(Cursorable<? extends T> source)
Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set. |
static
|
insertOrderSet(Iterator<? extends T> source)
Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set. |
static
|
insertOrderSet(T... source)
Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set. |
static
|
list()
Produces an empty JImmutableList built atop a 32-way tree. |
static
|
list(Collection<? extends T> source)
Produces a JImmutableList containing all of the values in source built atop a 32-way tree. |
static
|
list(Cursor<? extends T> source)
Produces a JImmutableList containing all of the values in source built atop a 32-way tree. |
static
|
list(Indexed<? extends T> source)
Produces a JImmutableList containing all of the values in source built atop a 32-way tree. |
static
|
list(Indexed<? extends T> source,
int offset,
int limit)
Produces a JImmutableList containing all of the values in the specified range from source
built atop a 32-way tree. |
static
|
list(Iterator<? extends T> source)
Produces a JImmutableList containing all of the values in source built atop a 32-way tree. |
static
|
list(JImmutableArray<? extends T> source)
Produces a JImmutableList containing all of the values in source built atop a 32-way tree. |
static
|
list(JImmutableSet<? extends T> source)
Produces a JImmutableList containing all of the values in source built atop a 32-way tree. |
static
|
list(List<? extends T> source)
Produces a JImmutableList containing all of the values in source built atop a 32-way tree. |
static
|
list(T... values)
Produces a JImmutableList containing all of the specified values built atop a 32-way tree. |
static
|
listBuilder()
Produces a MutableBuilder for efficiently constructing a JImmutableList built atop a 32-way tree. |
static
|
listMap()
Creates a list map with higher performance but no specific ordering of keys. |
static
|
map()
Constructs an empty unsorted map. |
static
|
map(JImmutableMap<K,V> source)
Constructs an unsorted map. |
static
|
map(Map<K,V> source)
Constructs an unsorted map. |
static
|
ralist()
Produces an empty JImmutableRandomAccessList built atop a 2-3 tree. |
static
|
ralist(Collection<? extends T> source)
Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree. |
static
|
ralist(Cursor<? extends T> source)
Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree. |
static
|
ralist(Cursorable<? extends T> source)
Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree. |
static
|
ralist(Iterator<? extends T> source)
Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree. |
static
|
ralist(T... source)
Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree. |
static
|
ralistBuilder()
Produces a MutableBuilder to efficiently construct a JImmutableRandomAccessList built atop a 2-3 tree. |
static
|
set()
Constructs an unsorted set. |
static
|
set(Collection<? extends T> source)
Constructs an unsorted set containing the values from source. |
static
|
set(Cursor<? extends T> source)
Constructs an unsorted set containing the values from source. |
static
|
set(Cursorable<? extends T> source)
Constructs an unsorted set containing the values from source. |
static
|
set(Iterator<? extends T> source)
Constructs an unsorted set containing the values from source. |
static
|
set(T... source)
Constructs an unsorted set containing the values from source. |
static
|
sortedListMap()
Creates a list map with keys sorted by their natural ordering. |
static
|
sortedListMap(Comparator<K> comparator)
Creates a list map with keys sorted by the specified Comparator. |
static
|
sortedMap()
Constructs an empty map that sorts keys in their natural sort order (using ComparableComparator). |
static
|
sortedMap(Comparator<K> comparator)
Constructs a map that sorts keys using the specified Comparator. |
static
|
sortedMap(Comparator<K> comparator,
JImmutableMap<K,V> source)
Constructs a map that sorts keys using the specified Comparator. |
static
|
sortedMap(Comparator<K> comparator,
Map<K,V> source)
Constructs a map that sorts keys using the specified Comparator. |
static
|
sortedMap(JImmutableMap<K,V> source)
Constructs a map that sorts keys in their natural sort order (using ComparableComparator). |
static
|
sortedMap(Map<K,V> source)
Constructs a map that sorts keys in their natural sort order (using ComparableComparator). |
static
|
sortedSet()
Constructs an empty set that sorts values in their natural sort order (using ComparableComparator). |
static
|
sortedSet(Collection<? extends T> source)
Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator). |
static
|
sortedSet(Comparator<T> comparator)
Constructs an empty set that sorts values using comparator. |
static
|
sortedSet(Comparator<T> comparator,
Collection<? extends T> source)
Constructs a set containing all of the values in source that sorts values using comparator. |
static
|
sortedSet(Comparator<T> comparator,
Cursor<? extends T> source)
Constructs a set containing all of the values in source that sorts values using comparator. |
static
|
sortedSet(Comparator<T> comparator,
Cursorable<? extends T> source)
Constructs a set containing all of the values in source that sorts values using comparator. |
static
|
sortedSet(Comparator<T> comparator,
Iterator<? extends T> source)
Constructs a set containing all of the values in source that sorts values using comparator. |
static
|
sortedSet(Comparator<T> comparator,
T... source)
Constructs a set containing all of the values in source that sorts values using comparator. |
static
|
sortedSet(Cursor<? extends T> source)
Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator). |
static
|
sortedSet(Cursorable<? extends T> source)
Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator). |
static
|
sortedSet(Iterator<? extends T> source)
Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator). |
static
|
sortedSet(T... source)
Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator). |
static
|
stack()
Produces an empty JImmutableStack. |
static
|
stack(Collection<? extends T> source)
Produces a JImmutableStack containing all of the values in source. |
static
|
stack(Cursor<? extends T> source)
Produces a JImmutableStack containing all of the values in source. |
static
|
stack(Cursorable<? extends T> source)
Produces a JImmutableStack containing all of the values in source. |
static
|
stack(Iterator<? extends T> source)
Produces a JImmutableStack containing all of the values in source. |
static
|
stack(T... source)
Produces a JImmutableStack containing all of the specified values. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
stack
public static <T> JImmutableStack<T> stack()
- Produces an empty JImmutableStack.
- Type Parameters:
T
-
- Returns:
stack
public static <T> JImmutableStack<T> stack(T... source)
- Produces a JImmutableStack containing all of the specified values. Note that values
are added to the stack in the order they appear in source which means they will be
retrieved in the opposite order from the stack (i.e. the last value in source will
be the first value retrieved from the stack).
- Type Parameters:
T
-
- Returns:
stack
public static <T> JImmutableStack<T> stack(Cursor<? extends T> source)
- Produces a JImmutableStack containing all of the values in source. Note that values
are added to the stack in the order they appear in source which means they will be
retrieved in the opposite order from the stack (i.e. the last value in source will
be the first value retrieved from the stack).
- Type Parameters:
T
-
- Returns:
stack
public static <T> JImmutableStack<T> stack(Cursorable<? extends T> source)
- Produces a JImmutableStack containing all of the values in source. Note that values
are added to the stack in the order they appear in source which means they will be
retrieved in the opposite order from the stack (i.e. the last value in source will
be the first value retrieved from the stack).
- Type Parameters:
T
-
- Returns:
stack
public static <T> JImmutableStack<T> stack(Iterator<? extends T> source)
- Produces a JImmutableStack containing all of the values in source. Note that values
are added to the stack in the order they appear in source which means they will be
retrieved in the opposite order from the stack (i.e. the last value in source will
be the first value retrieved from the stack).
- Type Parameters:
T
-
- Returns:
stack
public static <T> JImmutableStack<T> stack(Collection<? extends T> source)
- Produces a JImmutableStack containing all of the values in source. Note that values
are added to the stack in the order they appear in source which means they will be
retrieved in the opposite order from the stack (i.e. the last value in source will
be the first value retrieved from the stack).
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list()
- Produces an empty JImmutableList built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
listBuilder
public static <T> JImmutableList.Builder<T> listBuilder()
- Produces a MutableBuilder for efficiently constructing a JImmutableList built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(T... values)
- Produces a JImmutableList containing all of the specified values built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(Cursor<? extends T> source)
- Produces a JImmutableList containing all of the values in source built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(Indexed<? extends T> source)
- Produces a JImmutableList containing all of the values in source built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(Indexed<? extends T> source,
int offset,
int limit)
- Produces a JImmutableList containing all of the values in the specified range from source
built atop a 32-way tree. The values copied from source are those whose index are in the
range offset to (limit - 1).
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(JImmutableSet<? extends T> source)
- Produces a JImmutableList containing all of the values in source built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(JImmutableArray<? extends T> source)
- Produces a JImmutableList containing all of the values in source built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(Iterator<? extends T> source)
- Produces a JImmutableList containing all of the values in source built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(List<? extends T> source)
- Produces a JImmutableList containing all of the values in source built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
list
public static <T> JImmutableList<T> list(Collection<? extends T> source)
- Produces a JImmutableList containing all of the values in source built atop a 32-way tree.
- Type Parameters:
T
-
- Returns:
ralist
public static <T> JImmutableRandomAccessList<T> ralist()
- Produces an empty JImmutableRandomAccessList built atop a 2-3 tree.
Implementation note: Using a 2-3 tree provides maximum flexibility and good performance
for insertion and deletion anywhere in the list but is slower than the 32-way tree lists.
- Type Parameters:
T
-
- Returns:
ralistBuilder
public static <T> JImmutableRandomAccessList.Builder<T> ralistBuilder()
- Produces a MutableBuilder to efficiently construct a JImmutableRandomAccessList built atop a 2-3 tree.
Implementation note: Using a 2-3 tree provides maximum flexibility and good performance
for insertion and deletion anywhere in the list but is slower than the 32-way tree lists.
- Type Parameters:
T
-
- Returns:
ralist
public static <T> JImmutableRandomAccessList<T> ralist(T... source)
- Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree.
Implementation note: Using a 2-3 tree provides maximum flexibility and good performance
for insertion and deletion anywhere in the list but is slower than the 32-way tree lists.
- Type Parameters:
T
-
- Returns:
ralist
public static <T> JImmutableRandomAccessList<T> ralist(Cursor<? extends T> source)
- Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree.
Implementation note: Using a 2-3 tree provides maximum flexibility and good performance
for insertion and deletion anywhere in the list but is slower than the 32-way tree lists.
- Type Parameters:
T
-
- Returns:
ralist
public static <T> JImmutableRandomAccessList<T> ralist(Cursorable<? extends T> source)
- Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree.
Implementation note: Using a 2-3 tree provides maximum flexibility and good performance
for insertion and deletion anywhere in the list but is slower than the 32-way tree lists.
- Type Parameters:
T
-
- Returns:
ralist
public static <T> JImmutableRandomAccessList<T> ralist(Iterator<? extends T> source)
- Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree.
Implementation note: Using a 2-3 tree provides maximum flexibility and good performance
for insertion and deletion anywhere in the list but is slower than the 32-way tree lists.
- Type Parameters:
T
-
- Returns:
ralist
public static <T> JImmutableRandomAccessList<T> ralist(Collection<? extends T> source)
- Produces an empty JImmutableRandomAccessList containing all of the values in source built atop a 2-3 tree.
Implementation note: Using a 2-3 tree provides maximum flexibility and good performance
for insertion and deletion anywhere in the list but is slower than the 32-way tree lists.
- Type Parameters:
T
-
- Returns:
map
public static <K,V> JImmutableMap<K,V> map()
- Constructs an empty unsorted map.
Implementation note: The map will adopt a hash code collision strategy based on
the first key assigned to the map. All keys in the map must either implement Comparable (and
be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous keys in any map.
- Type Parameters:
K
- V
-
- Returns:
map
public static <K,V> JImmutableMap<K,V> map(Map<K,V> source)
- Constructs an unsorted map.
All key/value pairs from source are copied into the newly created map.
Implementation note: The map will adopt a hash code collision strategy based on
the first key in source. All keys in the map must either implement Comparable (and
be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous keys in any map.
- Type Parameters:
K
- V
- - Parameters:
source
-
- Returns:
map
public static <K,V> JImmutableMap<K,V> map(JImmutableMap<K,V> source)
- Constructs an unsorted map.
If source is already an unsorted map it is returned directly, otherwise a new map
is created and all key/value pairs from source are copied into the newly created map.
Implementation note: The map will adopt a hash code collision strategy based on
the first key in source. All keys in the map must either implement Comparable (and
be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous keys in any map.
- Type Parameters:
K
- V
- - Parameters:
source
-
- Returns:
sortedMap
public static <K extends Comparable<K>,V> JImmutableMap<K,V> sortedMap()
- Constructs an empty map that sorts keys in their natural sort order (using ComparableComparator).
sortedMap
public static <K extends Comparable<K>,V> JImmutableMap<K,V> sortedMap(Map<K,V> source)
- Constructs a map that sorts keys in their natural sort order (using ComparableComparator).
All key/value pairs from source are copied into the newly created map.
- Parameters:
source
- java.util.Map containing starting key/value pairs
sortedMap
public static <K extends Comparable<K>,V> JImmutableMap<K,V> sortedMap(JImmutableMap<K,V> source)
- Constructs a map that sorts keys in their natural sort order (using ComparableComparator).
All key/value pairs from source are copied into the newly created map.
If source is already a sorted map using the natural sort order it will be returned directly
(effectively performing a simple cast).
- Parameters:
source
- JImmutableMap containing starting key/value pairs
sortedMap
public static <K,V> JImmutableMap<K,V> sortedMap(Comparator<K> comparator)
- Constructs a map that sorts keys using the specified Comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
All key/value pairs from map are copied into the newly created map.
sortedMap
public static <K,V> JImmutableMap<K,V> sortedMap(Comparator<K> comparator,
Map<K,V> source)
- Constructs a map that sorts keys using the specified Comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
All key/value pairs from source are copied into the newly created map.
- Parameters:
source
- java.util.Map containing starting key/value pairs
sortedMap
public static <K,V> JImmutableMap<K,V> sortedMap(Comparator<K> comparator,
JImmutableMap<K,V> source)
- Constructs a map that sorts keys using the specified Comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
If source is already a sorted map that uses the same comparator (as indicated by comparator.equals())
then source will be returned directly. Otherwise all key/value pairs from source are copied into
the newly created map.
- Parameters:
source
- JImmutableMap containing starting key/value pairs
insertOrderMap
public static <K,V> JImmutableMap<K,V> insertOrderMap()
- Constructs an empty map whose cursors traverse elements in the same order that they
were originally added to the map. Similar to LinkedHapMap.
The map will adopt a hash code collision strategy based on
the first key assigned to the map. All keys in the map must either implement Comparable (and
be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous keys in any map.
- Type Parameters:
K
- V
-
- Returns:
insertOrderMap
public static <K,V> JImmutableMap<K,V> insertOrderMap(Map<K,V> source)
- Constructs a map whose cursors traverse elements in the same order that they
were originally added to the map. Similar to LinkedHapMap.
All key/value pairs from source are copied into the newly created map.
The map will adopt a hash code collision strategy based on
the first key in source. All keys in the map must either implement Comparable (and
be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous keys in any map.
- Type Parameters:
K
- V
- - Parameters:
source
-
- Returns:
insertOrderMap
public static <K,V> JImmutableMap<K,V> insertOrderMap(JImmutableMap<K,V> source)
- Constructs a map whose cursors traverse elements in the same order that they
were originally added to the map. Similar to LinkedHapMap.
If source is already an in order map it is returned directly, otherwise a new map
is created and all key/value pairs from source are copied into the newly created map.
In this case the iteration order for those entries would be based on the order of elements
returned by source's cursor.
The map will adopt a hash code collision strategy based on
the first key in source. All keys in the map must either implement Comparable (and
be comparable to all other keys in the map) or not implement Comparable. Attempting to use keys
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous keys in any map.
- Type Parameters:
K
- V
- - Parameters:
source
-
- Returns:
set
public static <T> JImmutableSet<T> set()
- Constructs an unsorted set.
Implementation note: The set will adopt a hash code collision strategy based on
the first value assigned to the set. All values in the map must either implement Comparable (and
be comparable to all other values in the set) or not implement Comparable. Attempting to use values
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous values in any set.
- Type Parameters:
T
-
- Returns:
set
public static <T> JImmutableSet<T> set(Cursor<? extends T> source)
- Constructs an unsorted set containing the values from source.
Implementation note: The set will adopt a hash code collision strategy based on
the first value in source. All values in the map must either implement Comparable (and
be comparable to all other values in the set) or not implement Comparable. Attempting to use values
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous values in any set.
- Type Parameters:
T
-
- Returns:
set
public static <T> JImmutableSet<T> set(T... source)
- Constructs an unsorted set containing the values from source.
Implementation note: The set will adopt a hash code collision strategy based on
the first value in source. All values in the map must either implement Comparable (and
be comparable to all other values in the set) or not implement Comparable. Attempting to use values
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous values in any set.
- Type Parameters:
T
-
- Returns:
set
public static <T> JImmutableSet<T> set(Cursorable<? extends T> source)
- Constructs an unsorted set containing the values from source.
Implementation note: The set will adopt a hash code collision strategy based on
the first value in source. All values in the map must either implement Comparable (and
be comparable to all other values in the set) or not implement Comparable. Attempting to use values
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous values in any set.
- Type Parameters:
T
-
- Returns:
set
public static <T> JImmutableSet<T> set(Iterator<? extends T> source)
- Constructs an unsorted set containing the values from source.
Implementation note: The set will adopt a hash code collision strategy based on
the first value in source. All values in the map must either implement Comparable (and
be comparable to all other values in the set) or not implement Comparable. Attempting to use values
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous values in any set.
- Type Parameters:
T
-
- Returns:
set
public static <T> JImmutableSet<T> set(Collection<? extends T> source)
- Constructs an unsorted set containing the values from source.
Implementation note: The set will adopt a hash code collision strategy based on
the first value in source. All values in the map must either implement Comparable (and
be comparable to all other values in the set) or not implement Comparable. Attempting to use values
some of which implement Comparable and some of which do not will lead to runtime errors. It is
always safest to use homogeneous values in any set.
- Type Parameters:
T
-
- Returns:
sortedSet
public static <T extends Comparable<T>> JImmutableSet<T> sortedSet()
- Constructs an empty set that sorts values in their natural sort order (using ComparableComparator).
sortedSet
public static <T extends Comparable<T>> JImmutableSet<T> sortedSet(T... source)
- Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator).
sortedSet
public static <T extends Comparable<T>> JImmutableSet<T> sortedSet(Cursor<? extends T> source)
- Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator).
sortedSet
public static <T extends Comparable<T>> JImmutableSet<T> sortedSet(Cursorable<? extends T> source)
- Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator).
sortedSet
public static <T extends Comparable<T>> JImmutableSet<T> sortedSet(Iterator<? extends T> source)
- Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator).
sortedSet
public static <T extends Comparable<T>> JImmutableSet<T> sortedSet(Collection<? extends T> source)
- Constructs a set containing all of the values in source that sorts values in their
natural sort order (using ComparableComparator).
sortedSet
public static <T> JImmutableSet<T> sortedSet(Comparator<T> comparator)
- Constructs an empty set that sorts values using comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
sortedSet
public static <T> JImmutableSet<T> sortedSet(Comparator<T> comparator,
Cursor<? extends T> source)
- Constructs a set containing all of the values in source that sorts values using comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
sortedSet
public static <T> JImmutableSet<T> sortedSet(Comparator<T> comparator,
T... source)
- Constructs a set containing all of the values in source that sorts values using comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
sortedSet
public static <T> JImmutableSet<T> sortedSet(Comparator<T> comparator,
Cursorable<? extends T> source)
- Constructs a set containing all of the values in source that sorts values using comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
sortedSet
public static <T> JImmutableSet<T> sortedSet(Comparator<T> comparator,
Iterator<? extends T> source)
- Constructs a set containing all of the values in source that sorts values using comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
sortedSet
public static <T> JImmutableSet<T> sortedSet(Comparator<T> comparator,
Collection<? extends T> source)
- Constructs a set containing all of the values in source that sorts values using comparator.
Note that the Comparator MUST BE IMMUTABLE.
The Comparator will be retained and used throughout the life of the map and its offspring and will
be aggressively shared so it is imperative that the Comparator be completely immutable.
insertOrderSet
public static <T> JImmutableSet<T> insertOrderSet()
- Constructs an empty set that sorts values based on the order they were originally added to the set.
- Type Parameters:
T
-
- Returns:
insertOrderSet
public static <T> JImmutableSet<T> insertOrderSet(Cursor<? extends T> source)
- Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set.
- Type Parameters:
T
-
- Returns:
insertOrderSet
public static <T> JImmutableSet<T> insertOrderSet(T... source)
- Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set.
- Type Parameters:
T
-
- Returns:
insertOrderSet
public static <T> JImmutableSet<T> insertOrderSet(Cursorable<? extends T> source)
- Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set.
- Type Parameters:
T
-
- Returns:
insertOrderSet
public static <T> JImmutableSet<T> insertOrderSet(Iterator<? extends T> source)
- Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set.
- Type Parameters:
T
-
- Returns:
insertOrderSet
public static <T> JImmutableSet<T> insertOrderSet(Collection<? extends T> source)
- Constructs a set containing all of the values in source that sorts values based on
the order they were originally added to the set.
- Type Parameters:
T
-
- Returns:
listMap
public static <K,V> JImmutableListMap<K,V> listMap()
- Creates a list map with higher performance but no specific ordering of keys.
- Type Parameters:
K
- V
-
- Returns:
insertOrderListMap
public static <K,V> JImmutableListMap<K,V> insertOrderListMap()
- Creates a list map with keys sorted by order they are inserted.
- Type Parameters:
K
- V
-
- Returns:
sortedListMap
public static <K extends Comparable<K>,V> JImmutableListMap<K,V> sortedListMap()
- Creates a list map with keys sorted by their natural ordering.
- Type Parameters:
K
- V
-
- Returns:
sortedListMap
public static <K,V> JImmutableListMap<K,V> sortedListMap(Comparator<K> comparator)
- Creates a list map with keys sorted by the specified Comparator. The Comparator MUST BE IMMUTABLE.
- Type Parameters:
K
- V
- - Parameters:
comparator
-
- Returns:
array
public static <T> JImmutableArray<T> array()
- Creates an empty sparse array that supports any integer (positive or negative) as an index.
Indexes do not need to be consecutive there can be gaps of any size between indexes.
- Type Parameters:
T
-
- Returns:
array
public static <T> JImmutableArray<T> array(T... source)
- Creates an empty sparse array that supports any integer (positive or negative) as an index.
Indexes do not need to be consecutive there can be gaps of any size between indexes.
Copies all values into the array starting at index zero.
- Type Parameters:
T
-
- Returns:
array
public static <T> JImmutableArray<T> array(Cursor<JImmutableMap.Entry<Integer,T>> source)
- Creates a sparse array containing all of the values from source that supports any integer
(positive or negative) as an index. Indexes do not need to be consecutive there can be gaps
of any size between indexes. Copies all entries into the array using each key as an index
for storing the corresponding value.
- Type Parameters:
T
-
- Returns:
array
public static <T> JImmutableArray<T> array(Indexed<? extends T> source)
- Creates a sparse array containing all of the values from source that supports any integer
(positive or negative) as an index. Indexes do not need to be consecutive there can be gaps
of any size between indexes. Copies all entries into the array using each key as an index
for storing the corresponding value.
- Type Parameters:
T
-
- Returns:
array
public static <T> JImmutableArray<T> array(Indexed<? extends T> source,
int offset,
int limit)
- Creates a sparse array containing all of the values in the specified range from source that
supports any integer (positive or negative) as an index. Indexes do not need to be
consecutive there can be gaps of any size between indexes. Copies all entries into the
array using each key as an index for storing the corresponding value. The values copied
from source are those whose index are in the range offset to (limit - 1).
- Type Parameters:
T
-
- Returns:
array
public static <T> JImmutableArray<T> array(List<? extends T> source)
- Creates a sparse array containing all of the values from source that supports any integer
(positive or negative) as an index. Indexes do not need to be consecutive there can be gaps
of any size between indexes. Copies all entries into the array using each key as an index
for storing the corresponding value.
- Type Parameters:
T
-
- Returns:
Copyright © 2014 Burton Computer Corporation. All rights reserved.