Package com.intellij.util.containers
Class ContainerUtil
java.lang.Object
com.intellij.util.containers.ContainerUtilRt
com.intellij.util.containers.ContainerUtil
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidadd(T element, Collection<T> result, Disposable parentDisposable) static <T,A extends T, C extends Collection<T>>
CaddAll(C collection, A... elements) static <T> voidaddAll(Collection<T> collection, Iterable<? extends T> appendix) static <T> voidaddAll(Collection<T> collection, Enumeration<? extends T> enumeration) static <T> voidaddAll(Collection<T> collection, Iterator<? extends T> iterator) static <T,A extends T, C extends Collection<T>>
CaddAllNotNull(C collection, A... elements) Adds all not-null elements from theelements, ignoring nullsstatic <T> voidaddAllNotNull(Collection<T> collection, Iterable<? extends T> elements) Adds all not-null elements from theelements, ignoring nullsstatic <T> voidaddAllNotNull(Collection<T> collection, Iterator<? extends T> elements) Adds all not-null elements from theelements, ignoring nullsstatic <T> booleanstatic <T> booleanstatic <T> List<T> static <T> T[]ar(T... elements) static <T> TObjectHashingStrategy<T> static <T> List<T> static <T> Set<T> collectSet(Iterator<T> iterator) static <T> List<T> Deprecated.static <T> List<T> concat(Iterable<? extends Collection<T>> list) static <T,V> List <T> concat(Iterable<? extends V> list, Function<V, Collection<? extends T>> listGenerator) static <T> List<T> static <T> List<T> static <T> List<T> static <T,V> List <T> concat(V[] array, Function<V, Collection<? extends T>> fun) static <T> booleancontainsIdentity(Iterable<T> list, T element) static <K,V> V[] static <T> CopyOnWriteArrayList<T> static <T> List<T> createMaybeSingletonList(T element) static <T> Set<T> createMaybeSingletonSet(T element) static <T> List<T> static <T> List<T> static <T> booleanequalsIdentity(List<T> list1, List<T> list2) static <T> booleanstatic <T> booleanstatic <T> List<T> filter(Collection<? extends T> collection, Condition<? super T> condition) static <K,V> Map <K, V> static <T> List<T> static <T> Tstatic <T,V extends T>
Vstatic <T> Tstatic <T,V extends T>
Vstatic <T> Tstatic <T> List<T> findAll(Collection<? extends T> collection, Condition<? super T> condition) static <T,V> List <V> findAll(Collection<? extends T> collection, Class<V> instanceOf) static <T> List<T> static <T,V> List <V> static <T,V> V[] findAllAsArray(Collection<? extends T> collection, Class<V> instanceOf) static <T> T[]findAllAsArray(T[] collection, Condition<? super T> instanceOf) static <T,V> V[] findAllAsArray(T[] collection, Class<V> instanceOf) static <T,U extends T>
UfindLastInstance(List<T> list, Class<U> clazz) static <E> List<E> flatten(Iterable<? extends Collection<E>> collections) static <E> List<E> flatten(Collection<E>[] collections) static <E> List<E> flattenIterables(Iterable<? extends Iterable<E>> collections) static <T> TgetFirstItem(Collection<T> items) static <T> TgetFirstItem(Collection<T> items, T defaultResult) static <T> TgetFirstItem(List<T> items) static <T> List<T> getFirstItems(List<T> items, int maxItems) The main difference fromsubListis thatgetFirstItemsdoes not throw any exceptions, even if maxItems is greater than size of the liststatic <T,V> V getOrCreate(Map<T, V> result, T key, V defaultValue) static <T> Tstatic <T,V> V static <T> TObjectHashingStrategy<T> static <E> ImmutableList<E> immutableList(E... array) static <E> ImmutableList<E> immutableList(List<E> list) static <K,V> ContainerUtil.ImmutableMapBuilder <K, V> static <E> Set<E> immutableSet(E... elements) static <T> intstatic <T> intstatic <T> intindexOfIdentity(List<T> list, T element) static <T> Collection<T> intersection(Collection<? extends T> collection1, Collection<? extends T> collection2) static <K,V> Map <K, V> intersection(Map<K, V> map1, Map<K, V> map2) static <T> booleanintersects(Collection<? extends T> collection1, Collection<? extends T> collection2) static <T> Iterator<T> iterate(Enumeration<T> enumeration) static <T> Iterator<T> iterate(T[] array) static <T> TiterateAndGetLastItem(Iterable<T> items) static <T> Iterable<T> iterateBackward(List<? extends T> list) static <T> intlastIndexOf(List<T> list, Condition<? super T> condition) static <T,U extends T>
intlastIndexOfInstance(List<T> list, Class<U> clazz) static <T> List<T> list(T... items) static <T,V> List <V> static <T,V> List <V> map(Collection<? extends T> iterable, Function<T, V> mapping) static <T,V> List <V> static <T,V> V[] static <T,V> V[] map2Array(Collection<? extends T> collection, Class<? super V> aClass, Function<T, V> mapper) static <T,V> V[] map2Array(Collection<? extends T> collection, V[] to, Function<T, V> mapper) static <T> Object[]map2Array(Collection<T> array, Function<T, Object> mapper) static <T> Object[]static <T,V> V[] static <T,KEY, VALUE>
Map<KEY, VALUE> map2Map(Collection<? extends T> collection, Function<T, Pair<KEY, VALUE>> mapper) static <KEY,VALUE>
Map<KEY, VALUE> map2Map(Collection<Pair<KEY, VALUE>> collection) static <T,KEY, VALUE>
Map<KEY, VALUE> static <T,KEY, VALUE>
Map<KEY, VALUE> map2MapNotNull(Collection<? extends T> collection, Function<T, Pair<KEY, VALUE>> mapper) static <T,KEY, VALUE>
Map<KEY, VALUE> map2MapNotNull(T[] collection, Function<T, Pair<KEY, VALUE>> mapper) static <T,U> Iterator <U> mapIterator(Iterator<T> iterator, Function<T, U> mapper) static <T,V> List <V> mapNotNull(Iterable<? extends T> iterable, Function<T, V> mapping) static <T,V> List <V> mapNotNull(Collection<? extends T> iterable, Function<T, V> mapping) static <T,V> List <V> mapNotNull(T[] array, Function<T, V> mapping) static <T,V> V[] mapNotNull(T[] array, Function<T, V> mapping, V[] emptyArray) static voidmergeSortedArrays(TIntArrayList x1, TIntArrayList y1, TIntArrayList x2, TIntArrayList y2) Merge sorted points, which are sorted by x and with equal x by y.static <T> ArrayList<T> static <E> ArrayList<E> newArrayList(E... array) static <E> ArrayList<E> newArrayList(Iterable<? extends E> iterable) static <T> List<T> newArrayList(T[] elements, int start, int end) static <T> ArrayList<T> newArrayListWithCapacity(int size) newEnumMap(Class<K> keyType) static <K,V> HashMap <K, V> static <K,V> Map <K, V> newHashMap(Pair<K, ? extends V> first, Pair<K, ? extends V>... entries) static <K,V> Map <K, V> newHashMap(List<K> keys, List<V> values) static <K,V> HashMap <K, V> newHashMap(Map<? extends K, ? extends V> map) static <T> Set<T> newHashOrEmptySet(Iterable<? extends T> iterable) static <T> HashSet<T> static <T> HashSet<T> newHashSet(int initialCapacity) static <T> HashSet<T> newHashSet(Iterable<? extends T> iterable) static <T> HashSet<T> newHashSet(Iterator<? extends T> iterator) static <T> HashSet<T> newHashSet(T... elements) static <K,V> IdentityHashMap <K, V> static <K,V> THashMap <K, V> static <K> THashSet<K> static <K> THashSet<K> newIdentityTroveSet(int initialCapacity) static <K> THashSet<K> newIdentityTroveSet(Collection<K> collection) static <K,V> LinkedHashMap <K, V> static <K,V> LinkedHashMap <K, V> newLinkedHashMap(int capacity) static <K,V> LinkedHashMap <K, V> newLinkedHashMap(Pair<K, V> first, Pair<K, V>... entries) static <K,V> LinkedHashMap <K, V> newLinkedHashMap(Map<K, V> map) static <T> LinkedHashSet<T> static <T> LinkedHashSet<T> newLinkedHashSet(Iterable<? extends T> elements) static <T> LinkedHashSet<T> newLinkedHashSet(T... elements) static <T> LinkedList<T> static <T> LinkedList<T> newLinkedList(Iterable<? extends T> elements) static <T> LinkedList<T> newLinkedList(T... elements) static <T> List<T> static <T> List<T> newSmartList(T element) static <T> List<T> newSmartList(T... elements) static <T> Stack<T> newStack()static <T> Stack<T> newStack(Collection<T> initial) static <T> Stack<T> newStack(T... initial) static <K extends Comparable,V>
TreeMap<K, V> static <K extends Comparable,V>
TreeMap<K, V> newTreeMap(Map<K, V> map) static <T> TreeSet<T> static <T> TreeSet<T> newTreeSet(Iterable<? extends T> elements) static <T> TreeSet<T> newTreeSet(Comparator<? super T> comparator) static <T> TreeSet<T> newTreeSet(T... elements) static <K,V> THashMap <K, V> static <K,V> THashMap <K, V> newTroveMap(TObjectHashingStrategy<K> strategy) static <T> THashSet<T> static <T> THashSet<T> newTroveSet(TObjectHashingStrategy<T> strategy) static <T> THashSet<T> newTroveSet(TObjectHashingStrategy<T> strategy, Collection<T> elements) static <T> THashSet<T> newTroveSet(TObjectHashingStrategy<T> strategy, T... elements) static <T> THashSet<T> newTroveSet(Collection<T> elements) static <T> THashSet<T> newTroveSet(T... elements) static <T> List<T> newUnmodifiableList(List<? extends T> originalList) static <T> booleanstatic <T> booleanstatic <T> List<T> packNullables(T... elements) static <T> List<T> prepend values in front of the liststatic <T> booleanprocessSortedListsInOrder(List<T> list1, List<T> list2, Comparator<? super T> comparator, boolean mergeEqualItems, Processor<T> processor) static <K,V> void putIfNotNull(K key, V value, Map<K, V> result) static <T> voidquickSort(List<T> list, Comparator<? super T> comparator) static <T> booleanremoveAll(Collection<T> collection, T... elements) static <T> voidremoveDuplicates(Collection<T> collection) static <T> List<T> removeDuplicatesFromSorted(List<T> list, Comparator<? super T> comparator) Processes the list, remove all duplicates and return the list with unique elements.static <T> booleanretainAll(Collection<T> collection, Condition<? super T> condition) static <E> List<E> static <A,B> Map <B, A> reverseMap(Map<A, B> map) static <T> Set<T> set(T... items) static <T> List<T> skipNulls(Collection<? extends T> collection) static <T extends Comparable<T>>
voidstatic <T> voidsort(List<T> list, Comparator<? super T> comparator) static <T extends Comparable<T>>
voidsort(T[] a) static <T> voidsort(T[] a, Comparator<T> comparator) static <T> List<T> sorted(Iterable<T> list, Comparator<? super T> comparator) static <T extends Comparable<? super T>>
List<T> sorted(Collection<T> list) static <T> List<T> sorted(Collection<T> list, Comparator<? super T> comparator) static <T> List<T> static <T> Collection<T> subtract(Collection<T> from, Collection<T> what) static <E> voidswapElements(List<E> list, int index1, int index2) static <T> List<T> trimToSize(List<T> list) static <T> List<T> unfold(T t, NullableFunction<T, T> next) static <K,V> Map <K, V> static <T> Set<T> Methods inherited from class com.intellij.util.containers.ContainerUtilRt
addIfNotNull, addIfNotNull, map2List, map2List, map2Set, map2Set, newHashMap, toArray, toArray
-
Constructor Details
-
ContainerUtil
public ContainerUtil()
-
-
Method Details
-
ar
-
newHashMap
-
newHashMap
-
newHashMap
-
newHashMap
-
newTreeMap
-
newTreeMap
-
newLinkedHashMap
-
newLinkedHashMap
@NotNull @Contract(pure=true) public static <K,V> LinkedHashMap<K,V> newLinkedHashMap(int capacity) -
newLinkedHashMap
-
newLinkedHashMap
-
newTroveMap
-
newTroveMap
-
newEnumMap
-
canonicalStrategy
-
identityStrategy
-
newIdentityHashMap
-
newLinkedList
-
newLinkedList
-
newLinkedList
-
newArrayList
-
newArrayList
-
newArrayList
-
newArrayListWithCapacity
-
newArrayList
-
newUnmodifiableList
-
newSmartList
-
newSmartList
-
newSmartList
-
newHashSet
-
newHashSet
-
newHashSet
-
newHashSet
-
newHashSet
-
newHashOrEmptySet
-
newLinkedHashSet
-
newLinkedHashSet
-
newLinkedHashSet
@NotNull @Contract(pure=true) public static <T> LinkedHashSet<T> newLinkedHashSet(@NotNull T... elements) -
newTroveSet
-
newTroveSet
-
newTroveSet
-
newTroveSet
-
newTroveSet
@NotNull @Contract(pure=true) public static <T> THashSet<T> newTroveSet(@NotNull TObjectHashingStrategy<T> strategy, @NotNull Collection<T> elements) -
newTroveSet
-
newIdentityTroveSet
-
newIdentityTroveSet
-
newIdentityTroveSet
-
newIdentityTroveMap
-
newTreeSet
-
newTreeSet
-
newTreeSet
-
newTreeSet
-
reverse
-
union
-
union
-
immutableSet
-
immutableList
-
immutableList
-
immutableMapBuilder
@NotNull @Contract(pure=true) public static <K,V> ContainerUtil.ImmutableMapBuilder<K,V> immutableMapBuilder() -
getOrElse
-
intersection
-
diff
-
processSortedListsInOrder
-
subList
-
addAll
public static <T> void addAll(@NotNull Collection<T> collection, @NotNull Iterable<? extends T> appendix) -
addAll
public static <T> void addAll(@NotNull Collection<T> collection, @NotNull Iterator<? extends T> iterator) -
addAllNotNull
public static <T> void addAllNotNull(@NotNull Collection<T> collection, @NotNull Iterable<? extends T> elements) Adds all not-null elements from theelements, ignoring nulls -
addAllNotNull
public static <T> void addAllNotNull(@NotNull Collection<T> collection, @NotNull Iterator<? extends T> elements) Adds all not-null elements from theelements, ignoring nulls -
collect
-
collectSet
-
find
-
find
-
find
-
find
-
find
-
map2Map
-
map2Map
-
map2MapNotNull
-
map2MapNotNull
-
map2Map
-
map2Array
-
map2Array
-
map2Array
-
map2Array
-
map2Array
-
filter
-
findAll
-
filter
-
filter
-
findAll
-
skipNulls
-
findAll
-
findAllAsArray
-
findAllAsArray
-
findAllAsArray
-
findAll
-
removeDuplicates
-
stringMap
-
iterate
-
iterate
-
iterateBackward
-
zip
-
swapElements
-
addAll
public static <T> void addAll(@NotNull Collection<T> collection, @NotNull Enumeration<? extends T> enumeration) -
addAll
@NotNull public static <T,A extends T, C addAllC extends Collection<T>> (@NotNull C collection, @NotNull A... elements) -
addAllNotNull
@NotNull public static <T,A extends T, C addAllNotNullC extends Collection<T>> (@NotNull C collection, @NotNull A... elements) Adds all not-null elements from theelements, ignoring nulls -
removeAll
-
retainAll
public static <T> boolean retainAll(@NotNull Collection<T> collection, @NotNull Condition<? super T> condition) -
concat
-
concat
@NotNull @Contract(pure=true) public static <T> List<T> concat(@NotNull Iterable<? extends Collection<T>> list) - Returns:
- read-only list consisting of the elements from the collections stored in list added together
-
concat
@Deprecated @NotNull @Contract(pure=true) public static <T> List<T> concat(boolean appendTail, @NotNull List<? extends T> list, @NotNull T... values) Deprecated.Useappend(List, Object[])orprepend(List, Object[])instead- Parameters:
appendTail- specify whether additional values should be appended in front or after the list- Returns:
- read-only list consisting of the elements from specified list with some additional values
-
append
-
prepend
@NotNull @Contract(pure=true) public static <T> List<T> prepend(@NotNull List<? extends T> list, @NotNull T... values) prepend values in front of the list- Returns:
- read-only list consisting of values and the elements from specified list
-
concat
@NotNull @Contract(pure=true) public static <T> List<T> concat(@NotNull List<? extends T> list1, @NotNull List<? extends T> list2) - Returns:
- read-only list consisting of the two lists added together
-
concat
- Returns:
- read-only list consisting of the lists added together
-
concat
@NotNull @Contract(pure=true) public static <T> List<T> concat(@NotNull List<List<? extends T>> lists) - Returns:
- read-only list consisting of the lists added together
-
concat
@NotNull @Contract(pure=true) public static <T,V> List<T> concat(@NotNull Iterable<? extends V> list, @NotNull Function<V, Collection<? extends T>> listGenerator) - Returns:
- read-only list consisting of the lists (made by listGenerator) added together
-
intersects
@Contract(pure=true) public static <T> boolean intersects(@NotNull Collection<? extends T> collection1, @NotNull Collection<? extends T> collection2) -
intersection
@NotNull @Contract(pure=true) public static <T> Collection<T> intersection(@NotNull Collection<? extends T> collection1, @NotNull Collection<? extends T> collection2) - Returns:
- read-only collection consisting of elements from both collections
-
getFirstItem
-
getFirstItem
-
getFirstItem
@Contract(pure=true) public static <T> T getFirstItem(@Nullable Collection<T> items, @Nullable T defaultResult) -
getFirstItems
@NotNull @Contract(pure=true) public static <T> List<T> getFirstItems(@NotNull List<T> items, int maxItems) The main difference fromsubListis thatgetFirstItemsdoes not throw any exceptions, even if maxItems is greater than size of the list- Type Parameters:
T- type of list- Parameters:
items- listmaxItems- size of the result will be equal or less thanmaxItems- Returns:
- new list with no more than
maxItemsfirst elements
-
iterateAndGetLastItem
-
mapIterator
-
subtract
@NotNull @Contract(pure=true) public static <T> Collection<T> subtract(@NotNull Collection<T> from, @NotNull Collection<T> what) - Returns:
- read-only collection consisting of elements from the 'from' collection which are absent from the 'what' collection
-
sort
-
sort
-
sort
-
sorted
@NotNull @Contract(pure=true) public static <T> List<T> sorted(@NotNull Collection<T> list, @NotNull Comparator<? super T> comparator) -
sorted
-
sorted
@NotNull @Contract(pure=true) public static <T extends Comparable<? super T>> List<T> sorted(@NotNull Collection<T> list) -
sort
-
map
@NotNull @Contract(pure=true) public static <T,V> List<V> map(@NotNull Iterable<? extends T> iterable, @NotNull Function<T, V> mapping) - Returns:
- read-only list consisting of the elements from the iterable converted by mapping
-
map
@NotNull @Contract(pure=true) public static <T,V> List<V> map(@NotNull Collection<? extends T> iterable, @NotNull Function<T, V> mapping) - Returns:
- read-only list consisting of the elements from the iterable converted by mapping
-
mapNotNull
@NotNull @Contract(pure=true) public static <T,V> List<V> mapNotNull(@NotNull T[] array, @NotNull Function<T, V> mapping) - Returns:
- read-only list consisting of the elements from the array converted by mapping with nulls filtered out
-
mapNotNull
@NotNull @Contract(pure=true) public static <T,V> V[] mapNotNull(@NotNull T[] array, @NotNull Function<T, V> mapping, @NotNull V[] emptyArray) - Returns:
- read-only list consisting of the elements from the array converted by mapping with nulls filtered out
-
mapNotNull
@NotNull @Contract(pure=true) public static <T,V> List<V> mapNotNull(@NotNull Iterable<? extends T> iterable, @NotNull Function<T, V> mapping) - Returns:
- read-only list consisting of the elements from the iterable converted by mapping with nulls filtered out
-
mapNotNull
@NotNull @Contract(pure=true) public static <T,V> List<V> mapNotNull(@NotNull Collection<? extends T> iterable, @NotNull Function<T, V> mapping) - Returns:
- read-only list consisting of the elements from the array converted by mapping with nulls filtered out
-
packNullables
- Returns:
- read-only list consisting of the elements with nulls filtered out
-
map
@NotNull @Contract(pure=true) public static <T,V> List<V> map(@NotNull T[] array, @NotNull Function<T, V> mapping) - Returns:
- read-only list consisting of the elements from the array converted by mapping
-
map
-
set
-
putIfNotNull
-
add
public static <T> void add(T element, @NotNull Collection<T> result, @NotNull Disposable parentDisposable) -
createMaybeSingletonList
-
createMaybeSingletonSet
-
getOrCreate
-
getOrElse
-
and
-
and
-
exists
-
exists
-
or
-
or
-
unfold
-
dropTail
-
list
-
quickSort
-
mergeSortedArrays
public static void mergeSortedArrays(@NotNull TIntArrayList x1, @NotNull TIntArrayList y1, @NotNull TIntArrayList x2, @NotNull TIntArrayList y2) Merge sorted points, which are sorted by x and with equal x by y. Result is put to x1 y1. -
flatten
@NotNull @Contract(pure=true) public static <E> List<E> flatten(@NotNull Collection<E>[] collections) - Returns:
- read-only list consisting of the elements from all of the collections
-
removeDuplicatesFromSorted
@NotNull public static <T> List<T> removeDuplicatesFromSorted(@NotNull List<T> list, @NotNull Comparator<? super T> comparator) Processes the list, remove all duplicates and return the list with unique elements.- Parameters:
list- must be sorted (according to the comparator), all elements must be not-null
-
flatten
@NotNull @Contract(pure=true) public static <E> List<E> flatten(@NotNull Iterable<? extends Collection<E>> collections) - Returns:
- read-only list consisting of the elements from all of the collections
-
flattenIterables
@NotNull @Contract(pure=true) public static <E> List<E> flattenIterables(@NotNull Iterable<? extends Iterable<E>> collections) - Returns:
- read-only list consisting of the elements from all of the collections
-
convert
-
containsIdentity
-
indexOfIdentity
-
equalsIdentity
-
indexOf
-
lastIndexOf
-
findLastInstance
-
lastIndexOfInstance
-
indexOf
-
reverseMap
-
trimToSize
-
newStack
-
newStack
-
newStack
-
emptyList
-
createEmptyCOWList
-
append(List, Object[])orprepend(List, Object[])instead