Package-level declarations

This package contains Guava Collections extensions, as well as collections wrappers to provide typed mutability.

Collection Types

The following is a list of guava's collection types, as well as their mutably-typed replacement.

BiMap

Guava BiMap

An extension of Map that guarantees the uniqueness of its values as well as that of its keys. This is sometimes called an "invertible map," since the restriction on values enables it to support an inverse view -- which is another instance of BiMap.

  • No wrappers for BiMap currently exist.

Multiset

Guava Multiset

An extension of Collection that may contain duplicate values like a List, yet has order-independent equality like a Set. One typical use for a multiset is to represent a histogram.

Multimap

Guava Multimap

A new type, which is similar to Map, but may contain multiple entries with the same key. Some behaviors of Multimap are left unspecified and are provided only by the subtypes mentioned below.

ListMultimap

Guava ListMultimap

An extension of Multimap which permits duplicate entries, supports random access of values for a particular key, and has partially order-dependent equality as defined by ListMultimap.equals(Object). ListMultimap takes its name from the fact that the collection of values associated with a given key fulfills the List contract.

SetMultimap

Guava SetMultimap

An extension of Multimap which has order-independent equality and does not allow duplicate entries; that is, while a key may appear twice in a SetMultimap, each must map to a different value. SetMultimap takes its name from the fact that the collection of values associated with a given key fulfills the Set contract.

SortedSetMultimap

Guava SortedSetMultimap

An extension of SetMultimap for which the collection values associated with a given key is a SortedSet.

Types

Link copied to clipboard
interface ListMultimap<K, out V> : Multimap<K, V>

A Multimap that can hold duplicate key-value pairs and that maintains the insertion ordering of values for a given key.

Link copied to clipboard
interface Multimap<K, out V> : Iterable<Map.Entry<K, V>>

A collection that holds pairs of objects (keys and values), however each key may be associated with multiple values.

Link copied to clipboard
interface Multiset<out E> : Collection<E>

A generic unordered collection that supports order-independent equality, like Set, but may have duplicate elements. A multiset is also sometimes called a bag.

Link copied to clipboard

A Multimap that can hold duplicate key-value pairs and that maintains the insertion ordering of values for a given key.

Link copied to clipboard

A collection that holds pairs of objects (keys and values), however each key may be associated with multiple values. Map keys are unique; the map holds only one value for each key.

Link copied to clipboard

A generic unordered collection that supports order-independent equality, like Set, but may have duplicate elements. A multiset is also sometimes called a bag.

Link copied to clipboard

A Multimap that cannot hold duplicate key-value pairs and that maintains the insertion ordering of values for a given key.

Link copied to clipboard
interface SetMultimap<K, out V> : Multimap<K, V>

A Multimap that cannot hold duplicate key-value pairs and that maintains the insertion ordering of values for a given key.

Link copied to clipboard

The backing collection type for multiset. Used by the Multiset builder inference methods.

Functions

Link copied to clipboard
inline fun <T> MutableCollection<T>.addAll(elementsToAdd: Iterable<T>): Boolean

Adds all elements in this to collection.

inline fun <T> MutableCollection<T>.addAll(iterator: Iterator<T>): Boolean

Adds all elements in iterator to this. The iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard
inline fun <T> Iterator<T>.advance(numberToAdvance: Int): Int

Calls next on this, either numberToAdvance times or until hasNext returns false, whichever comes first.

Link copied to clipboard
inline fun <T> Iterable<T>.all(noinline predicate: (T) -> Boolean): Boolean

Returns true if every element in this satisfies the predicate. If this is empty, true is returned.

inline fun <T> Iterator<T>.all(noinline predicate: (T) -> Boolean): Boolean

Returns true if every element returned by this satisfies the given predicate. If this is empty, true is returned.

Link copied to clipboard
inline fun <T> Iterable<T>.any(noinline predicate: (T) -> Boolean): Boolean

Returns true if any element in this satisfies the predicate.

inline fun <T> Iterator<T>.any(noinline predicate: (T) -> Boolean): Boolean

Returns true if one or more elements returned by this satisfy the given predicate.

Link copied to clipboard

Adapts an Iterator to the Enumeration interface.

Link copied to clipboard
inline fun <T> Iterable<T>.asString(): String

Returns a string representation of this, with the format [e1, e2, ..., en] (that is, identical to Arrays.toString(Iterables.toArray(iterable))). Note that for most implementations of Collection, collection.toString() also gives the same result, but that behavior is not generally guaranteed.

inline fun <T> Iterator<T>.asString(): String

Returns a string representation of this, with the format [e1, e2, ..., en]. The iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard
inline fun <K, V> buildListMultimap(builderAction: ImmutableListMultimap.Builder<K, V>.() -> Unit): ListMultimap<K, V>

Builds a new immutable list-multimap with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <K, V> buildMultimap(builderAction: ImmutableMultimap.Builder<K, V>.() -> Unit): Multimap<K, V>

Builds a new immutable multimap with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <E> buildMultiset(builderAction: ImmutableMultiset.Builder<E>.() -> Unit): Multiset<E>

Builds a new immutable multiset with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <K, V> buildMutableListMultimap(builderAction: MutableListMultimap<K, V>.() -> Unit): MutableListMultimap<K, V>

Builds a new mutable list-multimap with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <K, V> buildMutableMultimap(builderAction: MutableMultimap<K, V>.() -> Unit): MutableMultimap<K, V>

Builds a new mutable multimap with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <E> buildMutableMultiset(valueType: SetMultisetType = HASH_MULTISET, builderAction: MutableMultiset<E>.() -> Unit): MutableMultiset<E>

Builds a new multiset with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <K, V> buildMutableSetMultimap(builderAction: MutableSetMultimap<K, V>.() -> Unit): MutableSetMultimap<K, V>

Builds a new mutable set-multimap with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <K, V> buildSetMultimap(builderAction: ImmutableSetMultimap.Builder<K, V>.() -> Unit): SetMultimap<K, V>

Builds a new immutable set-multimap with the given builderAction, using the builder inference api.

Link copied to clipboard
inline fun <B> List<List<B>>.cartesianProduct(): List<List<B>>

Returns every possible list that can be formed by choosing one element from each of the given lists in order; the "n-ary Cartesian product" of the lists. For example:

Link copied to clipboard
inline fun <B> cartesianProductOf(vararg lists: List<B>): List<List<B>>

Returns every possible list that can be formed by choosing one element from each of the given lists in order; the "n-ary [Cartesian

Link copied to clipboard

Returns a view of the specified CharSequence as a List<Character>, viewing this as a sequence of Unicode code units. The view does not support any modification operations, but reflects any changes to the underlying character sequence.

Returns a view of the specified string as an immutable list of Char values.

Link copied to clipboard
inline fun <T> Iterable<T>.concat(vararg iterables: Iterable<T>): Iterable<T>
@JvmName(name = "concatMutable")
inline fun <T> MutableIterable<T>.concat(vararg iterables: MutableIterable<T>): MutableIterable<T>

Combines multiple iterables into a single iterable. The returned iterable has an iterator that traverses the elements in this, followed by the elements of each iterable in iterables sequentially. The source iterators are not polled until necessary.

infix inline fun <T> Iterable<T>.concat(other: Iterable<T>): Iterable<T>
@JvmName(name = "concatMutable")
infix inline fun <T> MutableIterable<T>.concat(other: MutableIterable<T>): MutableIterable<T>

Combines two iterables into a single iterable. The returned iterable has an iterator that traverses the elements in this, followed by the elements in other. The source iterators are not polled until necessary.

inline fun <T> Iterator<T>.concat(vararg iterators: Iterator<T>): Iterator<T>
@JvmName(name = "concatMutable")
inline fun <T> MutableIterator<T>.concat(vararg iterators: MutableIterator<T>): MutableIterator<T>

Combines two iterators into a single iterator. The returned iterator iterates across the elements in this, followed by the elements in iterators sequentially. The source iterators are not polled until necessary.

infix inline fun <T> Iterator<T>.concat(other: Iterator<T>): Iterator<T>
@JvmName(name = "concatMutable")
infix inline fun <T> MutableIterator<T>.concat(other: MutableIterator<T>): MutableIterator<T>

Combines two iterators into a single iterator. The returned iterator iterates across the elements in this, followed by the elements in other. The source iterators are not polled until necessary.

inline fun <T> Iterable<T>.concat(a: Iterable<T>, b: Iterable<T>): Iterable<T>
@JvmName(name = "concatMutable")
inline fun <T> MutableIterable<T>.concat(a: MutableIterable<T>, b: MutableIterable<T>): MutableIterable<T>

Combines three iterables into a single iterable. The returned iterable has an iterator that traverses the elements in this, followed by the elements in a, followed by the elements in b. The source iterators are not polled until necessary.

inline fun <T> Iterator<T>.concat(a: Iterator<T>, b: Iterator<T>): Iterator<T>
@JvmName(name = "concatMutable")
inline fun <T> MutableIterator<T>.concat(a: MutableIterator<T>, b: MutableIterator<T>): MutableIterator<T>

Combines three iterators into a single iterator. The returned iterator iterates across the elements in this, followed by the elements in a, followed by the elements in b. The source iterators are not polled until necessary.

inline fun <T> Iterable<T>.concat(a: Iterable<T>, b: Iterable<T>, c: Iterable<T>): Iterable<T>
@JvmName(name = "concatMutable")
inline fun <T> MutableIterable<T>.concat(a: MutableIterable<T>, b: MutableIterable<T>, c: MutableIterable<T>): MutableIterable<T>

Combines four iterables into a single iterable. The returned iterable has an iterator that traverses the elements in this, followed by the elements in a, followed by the elements in b, followed by the elements in c. The source iterators are not polled until necessary.

inline fun <T> Iterator<T>.concat(a: Iterator<T>, b: Iterator<T>, c: Iterator<T>): Iterator<T>
@JvmName(name = "concatMutable")
inline fun <T> MutableIterator<T>.concat(a: MutableIterator<T>, b: MutableIterator<T>, c: MutableIterator<T>): MutableIterator<T>

Combines two iterators into a single iterator. The returned iterator iterates across the elements in this, followed by the elements in a, followed by the elements in b, followed by the elements in c. The source iterators are not polled until necessary.

Link copied to clipboard
inline fun <T> concatNoDefensiveCopy(vararg inputs: Iterator<T>): Iterator<T>

Concats a varargs array of iterators without making a defensive copy of the array.

Link copied to clipboard

Returns a view of the supplied iterable that wraps each generated Iterator through Iterators.consumingIterator.

Link copied to clipboard

Returns a view of the supplied this that removes each element from the supplied this as it is returned.

Link copied to clipboard
inline fun <T> Iterator<T>.contains(element: T): Boolean

Returns true if this contains element.

Link copied to clipboard
inline fun <T> Iterable<T>.cycleIterable(): Iterable<T>
@JvmName(name = "cycleIterableMutable")
inline fun <T> MutableIterable<T>.cycleIterable(): MutableIterable<T>

Returns an iterable whose iterators cycle indefinitely over the elements of this.

inline fun <T> cycleIterable(vararg elements: T): Iterable<T>

Returns an iterable whose iterators cycle indefinitely over the provided elements.

Link copied to clipboard
inline fun <T> Iterable<T>.cycleIterator(): Iterator<T>
@JvmName(name = "cycleMutable")
inline fun <T> MutableIterable<T>.cycleIterator(): MutableIterator<T>

Returns an iterator that cycles indefinitely over the elements of this.

inline fun <T> cycleIterator(vararg elements: T): MutableIterator<T>

Returns an iterator that cycles indefinitely over the provided elements.

Link copied to clipboard
inline fun <T> Iterable<T>.elementsEqual(other: Iterable<T>): Boolean

Determines whether two iterables contain equal elements in the same order. More specifically, this method returns true if this and other contain the same number of elements and every element of other is equal to the corresponding element of other.

inline fun <T> Iterator<T>.elementsEqual(other: Iterator<T>): Boolean

Determines whether two iterators contain equal elements in the same order. More specifically, this method returns true if this and other contain the same number of elements and every element of this is equal to the corresponding element of other.

Link copied to clipboard

Returns an empty read-only ListMultimap.

Link copied to clipboard
fun <K, V> emptyMultimap(): Multimap<K, V>

Returns an empty read-only Multimap.

Link copied to clipboard

Returns an empty read-only Multiset.

Link copied to clipboard

Returns an empty read-only SetMultimap.

Link copied to clipboard

Returns a view of this containing all elements that are of the type T.

Link copied to clipboard
inline fun <E> Collection<E>.filterView(noinline predicate: (E) -> Boolean): Collection<E>
@JvmName(name = "filterMutable")
inline fun <E> MutableCollection<E>.filterView(noinline predicate: (E) -> Boolean): MutableCollection<E>

Returns the elements of this that satisfy a predicate. The returned collection is a live view of this; changes to one affect the other.

inline fun <T> Iterable<T>.filterView(noinline retainIfTrue: (T) -> Boolean): Iterable<T>
inline fun <T> Iterator<T>.filterView(noinline retainIfTrue: (T) -> Boolean): Iterator<T>

Returns a view of this containing all elements that satisfy the input predicate retainIfTrue.

Link copied to clipboard
inline fun <T> Iterable<T>.find(defaultValue: T? = null, noinline predicate: (T) -> Boolean): T

Returns the first element in this that satisfies the given predicate; use this method only when such an element is known to exist. If it is possible that no element will match, use tryFind or find instead.

inline fun <T> Iterator<T>.find(defaultValue: T? = null, noinline predicate: (T) -> Boolean): T

Returns the first element in this that satisfies the given predicate; use this method only when such an element is known to exist. The iterator will be left exhausted: its hasNext method will return false. If it is possible that no element will match, use Iterator.tryFind or Iterator.find instead.

Link copied to clipboard
inline fun <T> Iterable<Iterable<T>>.flatConcat(): Iterable<T>
@JvmName(name = "flatConcatMutable")
inline fun <T> Iterable<MutableIterable<T>>.flatConcat(): MutableIterable<T>

Combines multiple iterables into a single iterable. The returned iterable has an iterator that traverses the elements in this sequentially. The source iterators are not polled until necessary.

inline fun <T> Iterable<Iterator<T>>.flatConcat(): Iterator<T>
@JvmName(name = "flatConcatMutable")
inline fun <T> Iterable<MutableIterator<T>>.flatConcat(): MutableIterator<T>
inline fun <T> Iterator<Iterator<T>>.flatConcat(): Iterator<T>
@JvmName(name = "flatConcatMutable")
inline fun <T> Iterator<MutableIterator<T>>.flatConcat(): MutableIterator<T>

Combines two iterators into a single iterator. The returned iterator iterates across the elements in this sequentially. The source iterators are not polled until necessary.

Link copied to clipboard
inline fun <T> forArray(vararg array: T): Iterator<T>

Returns an iterator containing the elements of array in order. The returned iterator is a view of the array; subsequent changes to the array will be reflected in the iterator.

Link copied to clipboard

Adapts an Enumeration to the Iterator interface.

Link copied to clipboard
inline fun <T> Iterable<T>.frequency(element: T): Int

Returns the number of elements in the specified iterable that equal the specified object. This implementation avoids a full iteration when the iterable is a Multiset or Set.

inline fun <T> Iterator<T>.frequency(element: T): Int

Returns the number of elements in the specified iterator that equal the specified object. The iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard
inline operator fun <T> Iterable<T>.get(position: Int): T

Returns the element at the specified position in an iterable.

inline operator fun <T> Iterator<T>.get(position: Int): T

Advances thisposition + 1` times, returning the element at the positionth position.

inline fun <T> Iterable<T>.get(position: Int, defaultValue: T? = null): T

Returns the element at the specified position in an iterable or a default value otherwise.

inline fun <T> Iterator<T>.get(position: Int, defaultValue: T? = null): T

Advances thisposition + 1` times, returning the element at the positionth position or a default value otherwise.

Link copied to clipboard
inline fun <T> Iterable<T>.getFirst(defaultValue: T): T

Returns the first element in this or defaultValue if the iterable is empty. The Iterators analog to this method is Iterators.getNext.

Link copied to clipboard
inline fun <T> Iterable<T>.getLast(defaultValue: T? = null): T

Returns the last element of this or defaultValue if the iterable is empty. If this is a List with RandomAccess support, then this operation is guaranteed to be O(1).

inline fun <T> Iterator<T>.getLast(defaultValue: T? = null): T

Advances this to the end, returning the last element or defaultValue if the iterator is empty and defaultValue is not null.

Link copied to clipboard
inline fun <T> Iterator<T>.getNext(defaultValue: T): T

Returns the next element in this or defaultValue if the iterator is empty. The Iterables analog to this method is Iterables.getFirst.

Link copied to clipboard
inline fun <T> Iterable<T>.indexOf(noinline predicate: (T) -> Boolean): Int

Returns the index in this of the first element that satisfies the provided predicate, or -1 if the Iterable has no such elements.

inline fun <T> Iterator<T>.indexOf(noinline predicate: (T) -> Boolean): Int

Returns the index in this of the first element that satisfies the provided predicate, or -1 if the Iterator has no such elements.

Link copied to clipboard
inline fun <T> Iterable<T>.isEmpty(): Boolean

Determines if the given iterable contains no elements.

Link copied to clipboard
inline fun <T> Iterable<T>.limit(limitSize: Int): Iterable<T>

Returns a view of this containing its first limitSize elements. If this contains fewer than limitSize elements, the returned view contains all of its elements. The returned iterable's iterator supports remove() if this's iterator does.

inline fun <T> Iterator<T>.limit(limitSize: Int): Iterator<T>

Returns a view containing the first limitSize elements of this. If this contains fewer than limitSize elements, the returned view contains all of its elements.

@JvmName(name = "limitMutable")
inline fun <T> MutableIterator<T>.limit(limitSize: Int): MutableIterator<T>

Returns a view containing the first limitSize elements of this. If this contains fewer than limitSize elements, the returned view contains all of its elements. The returned iterator supports remove() if iterator does.

Link copied to clipboard

Returns an empty read-only ListMultimap.

fun <K, V> listMultimapOf(vararg elements: Pair<K, V>): ListMultimap<K, V>
@JvmName(name = "listMultimapOfCollection")
fun <K, V> listMultimapOf(vararg elements: Pair<K, Collection<V>>): ListMultimap<K, V>

Returns a new read-only ListMultimap of given elements.

Link copied to clipboard
inline fun <T, R : Comparable<R>> Iterable<Iterable<T>>.mergeSorted(crossinline selector: (T) -> Comparable<R>): Iterable<T>

Returns an iterable over the merged contents of all given Iterables in this. Equivalent entries will not be de-duplicated.

inline fun <T, R : Comparable<R>> Iterable<Iterator<T>>.mergeSorted(crossinline selector: (T) -> Comparable<R>): Iterator<T>

Returns an iterator over the merged contents of all given this, traversing every element of the input iterators. Equivalent entries will not be de-duplicated.

Link copied to clipboard

Returns an unmodifiable view of the difference of two multisets. In the returned multiset, the count of each element is the result of the zero-truncated subtraction of its count in the second multiset from its count in the first multiset, with elements that would have a count of 0 not included. The iteration order of the returned multiset matches that of the element set of this, with repeated occurrences of the same element appearing consecutively.

Link copied to clipboard
fun <K, V> multimapOf(): Multimap<K, V>

Returns an empty read-only Multimap.

fun <K, V> multimapOf(vararg elements: Pair<K, V>): Multimap<K, V>
@JvmName(name = "multimapOfCollection")
fun <K, V> multimapOf(vararg elements: Pair<K, Collection<V>>): Multimap<K, V>

Returns a new read-only Multimap of given elements.

Link copied to clipboard

Returns an empty read-only Multiset.

fun <T> multisetOf(vararg elements: T): Multiset<T>

Returns a new read-only Multiset of given elements.

Link copied to clipboard

Returns an empty new MutableListMultimap.

fun <K, V> mutableListMultimapOf(vararg elements: Pair<K, V>): MutableListMultimap<K, V>
@JvmName(name = "mutableListMultimapOfCollection")
fun <K, V> mutableListMultimapOf(vararg elements: Pair<K, Collection<V>>): MutableListMultimap<K, V>

Returns a new MutableListMultimap with the given elements.

Link copied to clipboard

Returns an empty new Multimap.

fun <K, V> mutableMultimapOf(vararg elements: Pair<K, V>): MutableMultimap<K, V>

Returns a new Multimap with the given elements.

@JvmName(name = "mutableMultimapOfCollection")
fun <K, V> mutableMultimapOf(vararg elements: Pair<K, Collection<V>>): MutableMultimap<K, V>

Returns a new MutableMultimap with the given elements.

Link copied to clipboard

Returns an empty new MutableMultiset.

fun <T> mutableMultisetOf(vararg elements: T): MutableMultiset<T>

Returns a new MutableMultiset with the given elements.

Link copied to clipboard

Returns an empty new MutableMultimap.

fun <K, V> mutableSetMultimapOf(vararg elements: Pair<K, V>): MutableSetMultimap<K, V>
@JvmName(name = "mutableSetMultimapOfCollection")
fun <K, V> mutableSetMultimapOf(vararg elements: Pair<K, Collection<V>>): MutableSetMultimap<K, V>

Returns a new MutableMultimap with the given elements.

Link copied to clipboard

Returns a Collection of all the permutations of the specified Iterable using naturalOrder for establishing the lexicographical ordering.

Returns a Collection of all the permutations of the specified Iterable using the specified comparator for establishing the lexicographical ordering.

Returns a Collection of all the permutations of the specified Iterable using the specified selector for establishing the lexicographical ordering.

Link copied to clipboard
inline fun <T> Iterable<T>.paddedPartition(size: Int): Iterable<List<T?>>

Divides an iterable into unmodifiable sublists of the given size, padding the final iterable with null values if necessary. For example, partitioning an iterable containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e, null]] -- an outer iterable containing two inner lists of three elements each, all in the original order.

inline fun <T> Iterator<T>.paddedPartition(size: Int): Iterator<List<T?>>

Divides an iterator into unmodifiable sublists of the given size, padding the final iterator with null values if necessary. For example, partitioning an iterator containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e, null]] -- an outer iterator containing two inner lists of three elements each, all in the original order.

Link copied to clipboard
inline fun <T> Iterable<T>.partition(size: Int): Iterable<List<T>>

Divides an iterable into unmodifiable sublists of the given size (the final iterable may be smaller). For example, partitioning an iterable containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e]] -- an outer iterable containing two inner lists of three and two elements, all in the original order.

inline fun <T> Iterator<T>.partition(size: Int): Iterator<List<T>>

Divides an iterator into unmodifiable sublists of the given size (the final list may be smaller). For example, partitioning an iterator containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e]] -- an outer iterator containing two inner lists of three and two elements, all in the original order.

fun <T> List<T>.partition(size: Int): List<List<T>>

Returns consecutive sublists of a list, each of the same size (the final list may be smaller). For example, partitioning a list containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e]] -- an outer list containing two inner lists of three and two elements, all in the original order.

Link copied to clipboard

Returns a PeekingIterator backed by the given iterator.

Link copied to clipboard

Returns a Collection of all the permutations of the specified Collection.

Link copied to clipboard

Returns an unmodifiable view of the sum of two multisets. In the returned multiset, the count of each element is the sum of its counts in the two backing multisets. The iteration order of the returned multiset matches that of the element set of this followed by the members of the element set of other that are not contained in other, with repeated occurrences of the same element appearing consecutively.

Link copied to clipboard
inline fun <T> MutableIterable<T>.removeAll(elementsToRemove: Collection<T>): Boolean

Removes, from an iterable, every element that belongs to the provided collection.

inline fun <T> MutableIterator<T>.removeAll(elementsToRemove: Collection<T>): Boolean

Traverses an iterator and removes every element that belongs to the provided collection. The iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard
inline fun <T> MutableIterable<T>.removeIf(noinline predicate: (T) -> Boolean): Boolean

Removes, from an iterable, every element that satisfies the provided predicate.

inline fun <T> MutableIterator<T>.removeIf(noinline predicate: (T) -> Boolean): Boolean

Removes every element that satisfies the provided predicate from the iterator. The iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard
inline fun <T> MutableIterable<T>.retainAll(elementsToRetain: Collection<T>): Boolean

Removes, from an iterable, every element that does not belong to the provided collection.

inline fun <T> MutableIterator<T>.retainAll(elementsToRetain: Collection<T>): Boolean

Traverses an iterator and removes every element that does not belong to the provided collection. The iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard

Returns an empty read-only SetMultimap.

fun <K, V> setMultimapOf(vararg elements: Pair<K, V>): SetMultimap<K, V>
@JvmName(name = "setMultimapOfCollection")
fun <K, V> setMultimapOf(vararg elements: Pair<K, Collection<V>>): SetMultimap<K, V>

Returns a new read-only SetMultimap of given elements.

Link copied to clipboard
inline fun <T> T.singletonIterator(): Iterator<T>

Returns an iterator containing only this.

Link copied to clipboard
inline fun <T> Iterable<T>.skip(numberToSkip: Int): Iterable<T>
@JvmName(name = "skipMutable")
inline fun <T> MutableIterable<T>.skip(numberToSkip: Int): Iterable<T>

Returns a view of this that skips its first numberToSkip elements. If this contains fewer than numberToSkip elements, the returned iterable skips all of its elements.

Link copied to clipboard

Transforms a ListMultimap into its immutable guava equivalent

Transforms a Multimap into its immutable guava equivalent

Transforms a Multiset into its immutable guava equivalent

Transforms a MutableListMultimap into its guava equivalent

Transforms a MutableMultimap into its guava equivalent

Transforms a MutableMultiset into its guava equivalent

Transforms a MutableSetMultimap into its guava equivalent

Transforms a SetMultimap into its immutable guava equivalent

Link copied to clipboard

Wraps an immutable guava list multimap into a ListMultimap instance.

Wraps an immutable guava multimap into a Multimap instance.

Wraps an immutable guava multiset into a Multiset instance.

Wraps an immutable guava set multimap into a SetMultimap instance.

Wraps a guava list multimap into a MutableListMultimap instance.

Wraps a guava multimap into a MutableMultimap instance.

Wraps a guava multiset into a MutableMultiset instance.

Wraps a guava set multimap into a MutableSetMultimap instance.

Link copied to clipboard

Returns a new ListMultimap filled with all elements of this multimap.

Link copied to clipboard
fun <K, V> Multimap<K, V>.toMultimap(): Multimap<K, V>

Returns a new Multiset filled with all elements of this multimap.

Link copied to clipboard

Returns a new Multiset filled with all elements of this collection.

Link copied to clipboard

Returns a new MutableListMultimap filled with all elements of this multimap.

Link copied to clipboard

Returns a new MutableMultimap filled with all elements of this multimap.

Link copied to clipboard

Returns a new MutableMultiset filled with all elements of this collection.

Link copied to clipboard

Returns a new MutableSetMultimap filled with all elements of this multimap.

Link copied to clipboard

Returns a new SetMultimap filled with all elements of this multimap.

Link copied to clipboard
inline fun <T> Iterable<T>.toTypedArray(): Array<out T>

Copies an iterable's elements into an array.

inline fun <T> Iterator<T>.toTypedArray(): Array<out T>

Copies an iterator's elements into an array. The iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard
inline fun <F, T> Collection<F>.transform(noinline function: (F) -> T): Collection<T>
@JvmName(name = "transformMutable")
inline fun <F, T> MutableCollection<F>.transform(noinline function: (F) -> T): MutableCollection<T>

Returns a collection that applies function to each element of this. The returned collection is a live view of this; changes to the base collection affects the returned one.

inline fun <F, T> Iterable<F>.transform(noinline function: (F) -> T): Iterable<T>
inline fun <F, T> Iterator<F>.transform(noinline function: (F) -> T): Iterator<T>
@JvmName(name = "transformMutable")
inline fun <F, T> MutableIterator<F>.transform(noinline function: (F) -> T): MutableIterator<T>

Returns a view containing the result of applying function to each element of this.

inline fun <F, T> List<F>.transform(noinline function: (F) -> T): List<T>
@JvmName(name = "transformMutable")
inline fun <F, T> MutableList<F>.transform(noinline function: (F) -> T): MutableList<T>

Returns a list that applies function to each element of this. The returned list is a transformed view of this; changes to this will be reflected in the returned list and vice versa.

@JvmName(name = "transformMutable")
inline fun <F, T> MutableIterable<F>.transform(noinline function: (F) -> T): MutableIterable<T>

Returns a view containing the result of applying function to each element of fromIterable.

Link copied to clipboard
inline fun <T> Iterable<T>.tryFind(noinline predicate: (T) -> Boolean): Optional<T>

Returns an Optional containing the first element in this that satisfies the given predicate, if such an element exists.

inline fun <T> Iterator<T>.tryFind(noinline predicate: (T) -> Boolean): Optional<T>

Returns an Optional containing the first element in this that satisfies the given predicate, if such an element exists. If no such element is found, an empty Optional will be returned from this method and the iterator will be left exhausted: its hasNext method will return false.

Link copied to clipboard

Returns an unmodifiable view of this.

Link copied to clipboard

Returns an unmodifiable view of this.

Properties

Link copied to clipboard
val Iterable<*>.size: Int

Returns the number of elements in this.

val Iterator<*>.size: Int

Returns the number of elements remaining in this. The iterator will be left exhausted: its hasNext method will return false.