public class ImmutableCollections extends Object
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
| Modifier and Type | Method and Description |
|---|---|
static <T> int |
binarySearch(ImmutableList<? extends Comparable<? super T>> il,
T key)
Search the immutable list for the specified object using the binary search algorithm.
|
static <T> int |
binarySearch(ImmutableList<? extends T> il,
T key,
Comparator<? super T> comparator)
Search the immutable list for the specified object using the binary search algorithm.
|
static boolean |
disjoint(Collection<?> c1,
ImmutableCollection<?> ic2)
Determine if an immutable collection and a (non immutable) collection have no common members
|
static boolean |
disjoint(ImmutableCollection<?> ic1,
Collection<?> c2)
Determine if an immutable collection and a (non immutable) collection have no common members
|
static boolean |
disjoint(ImmutableCollection<?> ic1,
ImmutableCollection<?> ic2)
Determine if two immutable collections have no common members.
|
static <T> ImmutableList<T> |
emptyImmutableList()
Return an immutable empty list.
|
static <T,V> ImmutableMap<T,V> |
emptyImmutableMap()
Return an immutable empty map.
|
static <T> ImmutableSet<T> |
emptyImmutableSet()
Return an immutable empty set.
|
static int |
frequency(ImmutableCollection<?> ic,
Object o)
Return the number of occurrences of an object in an immutable collection.
|
static int |
indexOfSubList(ImmutableList<?> source,
ImmutableList<?> target)
Returns the starting position of the first occurrence of the specified target list within the specified source list, or
-1 if there is no such occurrence.
|
static int |
indexOfSubList(ImmutableList<?> source,
List<?> target)
Returns the starting position of the first occurrence of the specified target list within the specified source list, or
-1 if there is no such occurrence.
|
static int |
indexOfSubList(List<?> source,
ImmutableList<?> target)
Returns the starting position of the first occurrence of the specified target list within the specified source list, or
-1 if there is no such occurrence.
|
static int |
lastIndexOfSubList(ImmutableList<?> source,
ImmutableList<?> target)
Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1
if there is no such occurrence.
|
static int |
lastIndexOfSubList(ImmutableList<?> source,
List<?> target)
Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1
if there is no such occurrence.
|
static int |
lastIndexOfSubList(List<?> source,
ImmutableList<?> target)
Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1
if there is no such occurrence.
|
static <T extends Object & Comparable<? super T>> |
max(ImmutableCollection<? extends T> ic)
Returns the maximum element of an immutable collection according to the natural ordering of its elements.
|
static <T> T |
max(ImmutableCollection<? extends T> ic,
Comparator<? super T> comparator)
Returns the maximum element of an immutable collection according to the natural ordering of its elements.
|
static <T extends Object & Comparable<? super T>> |
min(ImmutableCollection<? extends T> ic)
Returns the minimum element of an immutable collection according to the natural ordering of its elements.
|
static <T> T |
min(ImmutableCollection<? extends T> ic,
Comparator<? super T> comparator)
Returns the minimum element of an immutable collection according to the natural ordering of its elements.
|
public static <T> ImmutableSet<T> emptyImmutableSet()
T - the data type of the ImmutableSetpublic static <T,V> ImmutableMap<T,V> emptyImmutableMap()
T - the key type of the ImmutableMapV - the value type of the ImmutableMappublic static <T> ImmutableList<T> emptyImmutableList()
T - the data type of the ImmutableListpublic static <T> int binarySearch(ImmutableList<? extends Comparable<? super T>> il, T key)
T - the data type of the ImmutableListil - ImmutableList<?>; the list (must be ordered according to the natural ordering of Tkey - T; the element to search for.key is present in the list, the index of key, or, when key is not
present in the list (-(insertion point) - 1) where insertion point is the index
of key if it were contained in the list.public static <T> int binarySearch(ImmutableList<? extends T> il, T key, Comparator<? super T> comparator)
il - ImmutableList<?>; the list (must be ordered according to the comparatorkey - T; the element to search for.comparator - Comparator<? super T>; a comparator for Tkey is present in the list, the index of key, or, when key is not
present in the list (-(insertion point) - 1) where insertion point is the index
of key if it were contained in the list.public static boolean disjoint(ImmutableCollection<?> ic1, ImmutableCollection<?> ic2)
ic1 - ImmutableCollection<?> one immutable collectionic2 - ImmutableCollection<?> another immutable collectionpublic static boolean disjoint(ImmutableCollection<?> ic1, Collection<?> c2)
ic1 - ImmutableCollection<?> an immutable collectionc2 - Collection<?> a (mutable) collectionpublic static boolean disjoint(Collection<?> c1, ImmutableCollection<?> ic2)
c1 - Collection<?> a (mutable) collectionic2 - ImmutableCollection<?> an immutable collectionpublic static int indexOfSubList(ImmutableList<?> source, ImmutableList<?> target)
source - ImmutableList<?>; the list in which to find the first occurrence of targettarget - ImmutableList<?>; the pattern to find in sourcesource of the first occurrence of target or -1 if target
does not occur anywhere in sourcepublic static int indexOfSubList(ImmutableList<?> source, List<?> target)
source - ImmutableList<?>; the list in which to find the first occurrence of targettarget - List<?>; the pattern to find in sourcesource of the first occurrence of target or -1 if target
does not occur anywhere in sourcepublic static int indexOfSubList(List<?> source, ImmutableList<?> target)
source - List<?>; the list in which to find the first occurrence of targettarget - ImmutableList<?>; the pattern to find in sourcesource of the first occurrence of target or -1 if target
does not occur anywhere in sourcepublic static int lastIndexOfSubList(ImmutableList<?> source, ImmutableList<?> target)
source - ImmutableList<?>; the list in which to find the last occurrence of targettarget - ImmutableList<?>; the pattern to find in sourcesource of the last occurrence of target or -1 if target
does not occur anywhere in sourcepublic static int lastIndexOfSubList(ImmutableList<?> source, List<?> target)
source - ImmutableList<?>; the list in which to find the last occurrence of targettarget - List<?>; the pattern to find in sourcesource of the last occurrence of target or -1 if target
does not occur anywhere in sourcepublic static int lastIndexOfSubList(List<?> source, ImmutableList<?> target)
source - List<?>; the list in which to find the last occurrence of targettarget - ImmutableList<?>; the pattern to find in sourcesource of the last occurrence of target or -1 if target
does not occur anywhere in sourcepublic static <T extends Object & Comparable<? super T>> T max(ImmutableCollection<? extends T> ic)
ic - ImmutableCollection<T extends Object & Comparable<? super T>>; the immutable collectionNoSuchElementException - if the immutable collection is empty.public static <T> T max(ImmutableCollection<? extends T> ic, Comparator<? super T> comparator)
ic - ImmutableCollection<T extends Object & Comparable<? super T>>; the immutable collectioncomparator - Comparator<? super T>; a comparator for TNoSuchElementException - if the immutable collection is empty.public static <T extends Object & Comparable<? super T>> T min(ImmutableCollection<? extends T> ic)
ic - ImmutableCollection<T extends Object & Comparable<? super T>>; the immutable collectionNoSuchElementException - if the immutable collection is empty.public static <T> T min(ImmutableCollection<? extends T> ic, Comparator<? super T> comparator)
ic - ImmutableCollection<T extends Object & Comparable<? super T>>; the immutable collectioncomparator - Comparator<? super T>; a comparator for TNoSuchElementException - if the immutable collection is empty.public static int frequency(ImmutableCollection<?> ic, Object o)
ic - ImmutableCollection; the immutable collectiono - Object; the object to count the number occurrences ofo in icCopyright © 2018–2019 Delft University of Technology. All rights reserved.