KtSet<T> class
abstract
A generic unordered collection of elements that does not support duplicate elements. Methods in this interface support only read-only access to the set; read/write access is supported through the KtMutableSet interface. @param E the type of elements contained in the set. The set is covariant on its element type.
- Implemented types
-
- KtCollection<
T>
- KtCollection<
- Implementers
- Available extensions
- ChainableKtIterableExtensions
- ChainableKtSetExtensions
- KtCollectionExtensions
- KtComparableIterableExtension
- KtDoubleIterableExtension
- KtIntIterableExtension
- KtIterableExtensions
- KtNumIterableExtension
- KtSetExtension
- NestedKtIterableExtensions
- NullableKtCollectionExtensions
- NullableKtSetExtensions
- RequireNoNullsKtIterableExtension
- UnzipKtIterableExtensions
Constructors
- KtSet.empty()
-
Returns an empty read-only set.
constfactory
-
KtSet.from([Iterable<
T> elements = const []]) -
Returns a new read-only set based on
elements
.factory - KtSet.of([T arg0, T arg1, T arg2, T arg3, T arg4, T arg5, T arg6, T arg7, T arg8, T arg9])
-
Returns a new read-only set of given elements.
factory
Properties
-
dart
→ Iterable<
T> -
Available on KtIterable<
Returns a dart:core IterableT> , provided by the KtIterableExtensions extensionno setter -
dart
→ Set<
T> -
Available on KtSet<
Returns a read-only dart:core SetT> , provided by the KtSetExtension extensionno setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
iter
→ Iterable<
T> -
Access to a Iterable to be used in for-loops
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
set
→ Set<
T> -
Deprecated, use asSet or iter for loops
no setter
- size → int
-
Returns the size of the collection.
no setteroverride
Methods
-
all(
bool predicate(T element)) → bool -
Available on KtIterable<
ReturnsT> , provided by the KtIterableExtensions extensiontrue
if all elements match the givenpredicate
. -
any(
[bool predicate(T element)?]) → bool -
Available on KtIterable<
ReturnsT> , provided by the KtIterableExtensions extensiontrue
if at least one element matches the givenpredicate
. -
asIterable(
) → KtIterable< T> -
Available on KtIterable<
Returns this collection as an Iterable.T> , provided by the KtIterableExtensions extension -
asSet(
) → Set< T> - returns a read-only dart:core Set
-
associate<
K, V> (KtPair< K, V> transform(T)) → KtMap<K, V> -
Available on KtIterable<
Returns a Map containing key-value pairs provided byT> , provided by the KtIterableExtensions extensiontransform
function applied to elements of the given collection. -
associateBy<
K> (K keySelector(T)) → KtMap< K, T> -
Available on KtIterable<
Returns a Map containing the elements from the given collection indexed by the key returned fromT> , provided by the KtIterableExtensions extensionkeySelector
function applied to each element. -
associateByTo<
K, V, M extends KtMutableMap< (K, V> >M destination, K keySelector(T), [V valueTransform(T)?]) → M -
Available on KtIterable<
Populates and returns theT> , provided by the KtIterableExtensions extensiondestination
mutable map with key-value pairs, where key is provided by thekeySelector
function and and value is provided by thevalueTransform
function applied to elements of the given collection. -
associateByTransform<
K, V> (K keySelector(T), V valueTransform(T)) → KtMap< K, V> -
Available on KtIterable<
Returns a Map containing the elements from the given collection indexed by the key returned fromT> , provided by the KtIterableExtensions extensionkeySelector
function applied to each element. The element can be transformed withvalueTransform
. -
associateTo<
K, V, M extends KtMutableMap< (K, V> >M destination, KtPair< K, V> transform(T)) → M -
Available on KtIterable<
Populates and returns theT> , provided by the KtIterableExtensions extensiondestination
mutable map with key-value pairs provided bytransform
function applied to each element of the given collection. -
associateWith<
V> (V valueSelector(T)) → KtMap< T, V> -
Available on KtIterable<
Returns a Map where keys are elements from the given collection and values are produced by theT> , provided by the KtIterableExtensions extensionvalueSelector
function applied to each element. -
associateWithTo<
V, M extends KtMutableMap> (M destination, V valueSelector(T)) → M -
Available on KtIterable<
Populates and returns theT> , provided by the KtIterableExtensions extensiondestination
mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by thevalueSelector
function applied to that key. -
average(
) → double -
Available on KtIterable<
Returns the average orT> , provided by the KtNumIterableExtension extensionnull
if there are no elements. -
averageBy(
num selector(T)) → double -
Available on KtIterable<
Returns an average value produced byT> , provided by the KtIterableExtensions extensionselector
function applied to each element in the collection. -
cast<
R> () → KtIterable< R> -
Available on KtIterable<
Provides a view of this KtIterable as an iterable ofT> , provided by the KtIterableExtensions extensionR
instances. -
chunked(
int size) → KtList< KtList< T> > -
Available on KtIterable<
Splits this collection into a list of lists each not exceeding the givenT> , provided by the KtIterableExtensions extensionsize
. -
chunkedTransform<
R> (int size, R transform(KtList< T> )) → KtList<R> -
Available on KtIterable<
Splits this collection into several lists each not exceeding the givenT> , provided by the KtIterableExtensions extensionsize
and applies the giventransform
function to an each. -
contains(
T element) → bool -
Checks if the specified element is contained in this collection.
override
-
contains(
T element) → bool -
Available on KtIterable<
ReturnsT> , provided by the KtIterableExtensions extensiontrue
ifelement
is found in the collection. -
containsAll(
KtCollection< T> elements) → bool -
Checks if all elements in the specified collection are contained in this collection.
override
-
count(
[bool predicate(T)?]) → int -
Available on KtIterable<
Returns the number of elements matching the givenT> , provided by the KtIterableExtensions extensionpredicate
or the number of elements whenpredicate = null
. -
distinct(
) → KtList< T> -
Available on KtIterable<
Returns a list containing only distinct elements from the given collection.T> , provided by the KtIterableExtensions extension -
distinctBy<
K> (K selector(T)) → KtList< T> -
Available on KtIterable<
Returns a list containing only elements from the given collection having distinct keys returned by the givenT> , provided by the KtIterableExtensions extensionselector
function. -
drop(
int n) → KtList< T> -
Available on KtIterable<
Returns a list containing all elements except firstT> , provided by the KtIterableExtensions extensionn
elements. -
dropWhile(
bool predicate(T)) → KtList< T> -
Available on KtIterable<
Returns a list containing all elements except first elements that satisfy the givenT> , provided by the KtIterableExtensions extensionpredicate
. -
elementAt(
int index) → T -
Available on KtIterable<
Returns an element at the givenT> , provided by the KtIterableExtensions extensionindex
or throws an IndexOutOfBoundsException if theindex
is out of bounds of this collection. -
elementAtOrElse(
int index, T defaultValue(int)) → T -
Available on KtIterable<
Returns an element at the givenT> , provided by the KtIterableExtensions extensionindex
or the result of calling thedefaultValue
function if theindex
is out of bounds of this collection. -
elementAtOrNull(
int index) → T? -
Available on KtIterable<
Returns an element at the givenT> , provided by the KtIterableExtensions extensionindex
ornull
if theindex
is out of bounds of this collection. -
filter(
bool predicate(T)) → KtList< T> -
Available on KtIterable<
Returns a list containing only elements matching the givenT> , provided by the KtIterableExtensions extensionpredicate
. -
filterIndexed(
bool predicate(int index, T)) → KtList< T> -
Available on KtIterable<
Returns a list containing only elements matching the givenT> , provided by the KtIterableExtensions extensionpredicate
. @parampredicate
function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element. -
filterIndexedTo<
C extends KtMutableCollection> (C destination, bool predicate(int index, T)) → C -
Available on KtIterable<
Appends all elements matching the givenT> , provided by the KtIterableExtensions extensionpredicate
to the givendestination
. @parampredicate
function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element. -
filterIsInstance<
R> () → KtList< R> -
Available on KtIterable<
Returns a list containing all elements that are instances of specified type parameter R.T> , provided by the KtIterableExtensions extension -
filterNot(
bool predicate(T)) → KtList< T> -
Available on KtIterable<
Returns a list containing all elements not matching the givenT> , provided by the KtIterableExtensions extensionpredicate
. -
filterNotNull(
) → KtList< T> -
Available on KtIterable<
Returns a list containing all elements that are notT?> , provided by the RequireNoNullsKtIterableExtension extensionnull
. -
filterNotNullTo<
C extends KtMutableCollection> (C destination) → C -
Available on KtIterable<
Appends all elements that are notT> , provided by the KtIterableExtensions extensionnull
to the givendestination
. -
filterNotTo<
C extends KtMutableCollection> (C destination, bool predicate(T)) → C -
Available on KtIterable<
Appends all elements not matching the givenT> , provided by the KtIterableExtensions extensionpredicate
to the givendestination
. -
filterTo<
C extends KtMutableCollection> (C destination, bool predicate(T)) → C -
Available on KtIterable<
Appends all elements matching the givenT> , provided by the KtIterableExtensions extensionpredicate
to the givendestination
. -
find(
bool predicate(T)) → T? -
Available on KtIterable<
Returns the first element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
, ornull
if no such element was found. -
findLast(
bool predicate(T)) → T? -
Available on KtIterable<
Returns the last element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
, ornull
if no such element was found. -
first(
[bool predicate(T)?]) → T -
Available on KtIterable<
Returns first element.T> , provided by the KtIterableExtensions extension -
firstNotNullOf<
R> (R? transform(T?)) → R -
Available on KtIterable<
Returns the first non-null value after applying the givenT> , provided by the KtIterableExtensions extensiontransform
function, throwing a NoSuchElementException exception if there is no such value. -
firstNotNullOfOrNull<
R> (R? transform(T?)) → R? -
Available on KtIterable<
Returns the first non-null value after applying the givenT> , provided by the KtIterableExtensions extensiontransform
function;null
will be returned if there is no such value. -
firstOrNull(
[bool predicate(T)?]) → T? -
Available on KtIterable<
Returns the first element (matchingT> , provided by the KtIterableExtensions extensionpredicate
when provided), ornull
if the collection is empty. -
flatMap<
R> (KtIterable< R> transform(T)) → KtList<R> -
Available on KtIterable<
Returns a single list of all elements yielded from results ofT> , provided by the KtIterableExtensions extensiontransform
function being invoked on each element of original collection. -
flatMapIndexed<
R> (KtIterable< R> transform(int index, T)) → KtList<R> -
Available on KtIterable<
Returns a single list of all elements yielded from results ofT> , provided by the KtIterableExtensions extensiontransform
function being invoked on each element and its index in the original collection. -
flatMapIndexedTo<
R, C extends KtMutableCollection< (R> >C destination, KtIterable< R> transform(int index, T)) → C -
Available on KtIterable<
Appends all elements yielded from results ofT> , provided by the KtIterableExtensions extensiontransform
function being invoked on each element and its index in the original collection, to the givendestination
. -
flatMapTo<
R, C extends KtMutableCollection< (R> >C destination, KtIterable< R> transform(T)) → C -
Available on KtIterable<
Appends all elements yielded from results ofT> , provided by the KtIterableExtensions extensiontransform
function being invoked on each element of original collection, to the givendestination
. -
flatten(
) → KtList< T> -
Available on KtIterable<
Returns a single list of all elements from all collections in the given collection.KtIterable< , provided by the NestedKtIterableExtensions extensionT> > -
fold<
R> (R initial, R operation(R acc, T)) → R -
Available on KtIterable<
Accumulates value starting withT> , provided by the KtIterableExtensions extensioninitial
value and applyingoperation
from left to right to current accumulator value and each element. -
foldIndexed<
R> (R initial, R operation(int index, R acc, T)) → R -
Available on KtIterable<
Accumulates value starting withT> , provided by the KtIterableExtensions extensioninitial
value and applyingoperation
from left to right to current accumulator value and each element with its index in the original collection. @paramoperation
function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value. -
forEach(
void action(T element)) → void -
Available on KtIterable<
Performs the givenT> , provided by the KtIterableExtensions extensionaction
on each element. -
forEachIndexed(
void action(int index, T element)) → void -
Available on KtIterable<
Performs the givenT> , provided by the KtIterableExtensions extensionaction
on each element, providing sequential index with the element. @paramaction
function that takes the index of an element and the element itself and performs the desired action on the element. -
groupBy<
K> (K keySelector(T)) → KtMap< K, KtList< T> > -
Available on KtIterable<
Groups elements of the original collection by the key returned by the givenT> , provided by the KtIterableExtensions extensionkeySelector
function applied to each element and returns a map where each group key is associated with a list of corresponding elements. -
groupByTo<
K, M extends KtMutableMap< (K, KtMutableList> >M destination, K keySelector(T)) → M -
Available on KtIterable<
Groups elements of the original collection by the key returned by the givenT> , provided by the KtIterableExtensions extensionkeySelector
function applied to each element and puts to thedestination
map each group key associated with a list of corresponding elements. -
groupByToTransform<
K, V, M extends KtMutableMap< (K, KtMutableList< >V> >M destination, K keySelector(T), V valueTransform(T)) → M -
Available on KtIterable<
Groups values returned by theT> , provided by the KtIterableExtensions extensionvalueTransform
function applied to each element of the original collection by the key returned by the givenkeySelector
function applied to the element and puts to thedestination
map each group key associated with a list of corresponding values. -
groupByTransform<
K, V> (K keySelector(T), V valueTransform(T)) → KtMap< K, KtList< V> > -
Available on KtIterable<
Groups values returned by theT> , provided by the KtIterableExtensions extensionvalueTransform
function applied to each element of the original collection by the key returned by the givenkeySelector
function applied to the element and returns a map where each group key is associated with a list of corresponding values. -
indexOf(
T element) → int -
Available on KtIterable<
Returns first index ofT> , provided by the KtIterableExtensions extensionelement
, or -1 if the collection does not contain element. -
indexOfFirst(
bool predicate(T)) → int -
Available on KtIterable<
Returns index of the first element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
, or -1 if the collection does not contain such element. -
indexOfLast(
bool predicate(T)) → int -
Available on KtIterable<
Returns index of the last element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
, or -1 if the collection does not contain such element. -
intersect(
KtIterable< T> other) → KtSet<T> -
Available on KtIterable<
Returns a set containing all elements that are contained by both this set and the specified collection.T> , provided by the KtIterableExtensions extension -
isEmpty(
) → bool -
Returns
true
if the collection is empty (contains no elements),false
otherwise.override -
isNotEmpty(
) → bool -
Available on KtCollection<
ReturnsT> , provided by the KtCollectionExtensions extensiontrue
if the collection is not empty. -
iterator(
) → KtIterator< T> -
Returns an iterator over the elements of this object.
override
-
joinToString(
{String separator = ", ", String prefix = "", String postfix = "", int limit = -1, String truncated = "...", String transform(T)?}) → String -
Available on KtIterable<
Creates a string from all the elements separated usingT> , provided by the KtIterableExtensions extensionseparator
and using the givenprefix
andpostfix
if supplied. -
last(
[bool predicate(T)?]) → T -
Available on KtIterable<
Returns the last element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
. @throws NoSuchElementException if no such element is found. -
lastIndexOf(
T element) → int -
Available on KtIterable<
Returns last index ofT> , provided by the KtIterableExtensions extensionelement
, or -1 if the collection does not contain element. -
lastOrNull(
[bool predicate(T)?]) → T? -
Available on KtIterable<
Returns the last element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
, ornull
if no such element was found. -
map<
R> (R transform(T)) → KtList< R> -
Available on KtIterable<
Returns a list containing the results of applying the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element in the original collection. -
mapIndexed<
R> (R transform(int index, T)) → KtList< R> -
Available on KtIterable<
Returns a list containing the results of applying the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element and its index in the original collection. @paramtransform
function that takes the index of an element and the element itself and returns the result of the transform applied to the element. -
mapIndexedNotNull<
R> (R? transform(int index, T)) → KtList< R> -
Available on KtIterable<
Returns a list containing only the non-null results of applying the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element and its index in the original collection. @paramtransform
function that takes the index of an element and the element itself and returns the result of the transform applied to the element. -
mapIndexedNotNullTo<
R, C extends KtMutableCollection< (R> >C destination, R? transform(int index, T)) → C -
Available on KtIterable<
Applies the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element and its index in the original collection and appends only the non-null results to the givendestination
. @paramtransform
function that takes the index of an element and the element itself and returns the result of the transform applied to the element. -
mapIndexedTo<
R, C extends KtMutableCollection< (R> >C destination, R transform(int index, T)) → C -
Available on KtIterable<
Applies the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element and its index in the original collection and appends the results to the givendestination
. @paramtransform
function that takes the index of an element and the element itself and returns the result of the transform applied to the element. -
mapNotNull<
R> (R? transform(T)) → KtList< R> -
Available on KtIterable<
Returns a list containing the results of applying the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element in the original collection. -
mapNotNullTo<
R, C extends KtMutableCollection< (R> >C destination, R? transform(T)) → C -
Available on KtIterable<
Applies the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element in the original collection and appends only the non-null results to the givendestination
. -
mapTo<
R, C extends KtMutableCollection< (R> >C destination, R transform(T)) → C -
Available on KtIterable<
Applies the givenT> , provided by the KtIterableExtensions extensiontransform
function to each element of the original collection and appends the results to the givendestination
. -
max(
) → T? -
Available on KtIterable<
Returns the largest element orT> , provided by the KtNumIterableExtension extensionnull
if there are no elements. -
max(
) → T? -
Available on KtIterable<
Returns the largest element orT> , provided by the KtComparableIterableExtension extensionnull
if there are no elements. -
maxBy<
R extends Comparable> (R selector(T)) → T? -
Available on KtIterable<
Returns the first element yielding the largest value of the given function orT> , provided by the KtIterableExtensions extensionnull
if there are no elements. -
maxOf<
R extends Comparable> (R selector(T)) → R -
Available on KtIterable<
Returns the largest value among all values produced by selector function applied to each element in the collection.T> , provided by the KtIterableExtensions extension -
maxOrNull(
) → T? -
Available on KtIterable<
Returns the largest element orT> , provided by the KtNumIterableExtension extensionnull
if there are no elements. -
maxOrNull(
) → T? -
Available on KtIterable<
Returns the largest element orT> , provided by the KtComparableIterableExtension extensionnull
if there are no elements. -
maxWith(
Comparator< T> comparator) → T? -
Available on KtIterable<
Returns the first element having the largest value according to the providedT> , provided by the KtIterableExtensions extensioncomparator
ornull
if there are no elements. -
min(
) → T? -
Available on KtIterable<
Returns the smallest element orT> , provided by the KtNumIterableExtension extensionnull
if there are no elements. -
min(
) → T? -
Available on KtIterable<
Returns the smallest element orT> , provided by the KtComparableIterableExtension extensionnull
if there are no elements. -
minBy<
R extends Comparable> (R selector(T)) → T? -
Available on KtIterable<
Returns the first element yielding the smallest value of the given function orT> , provided by the KtIterableExtensions extensionnull
if there are no elements. -
minOf<
R extends Comparable> (R selector(T)) → R -
Available on KtIterable<
Returns the smallest value among all values produced by selector function applied to each element in the array.T> , provided by the KtIterableExtensions extension -
minOrNull(
) → T? -
Available on KtIterable<
Returns the smallest element orT> , provided by the KtNumIterableExtension extensionnull
if there are no elements. -
minOrNull(
) → T? -
Available on KtIterable<
Returns the smallest element orT> , provided by the KtComparableIterableExtension extensionnull
if there are no elements. -
minus(
KtIterable< T> elements) → KtSet<T> -
Available on KtSet<
Returns a set containing all elements of the original collection except the elements contained in the givenT> , provided by the KtSetExtension extensionelements
collection. -
minus(
KtIterable< T> elements) → KtList<T> -
Available on KtIterable<
Returns a list containing all elements of the original collection except the elements contained in the givenT> , provided by the KtIterableExtensions extensionelements
collection. -
minusElement(
T element) → KtList< T> -
Available on KtIterable<
Returns a list containing all elements of the original collection without the first occurrence of the givenT> , provided by the KtIterableExtensions extensionelement
. -
minusElement(
T element) → KtSet< T> -
Available on KtSet<
Returns a set containing all elements of the original collection without the first occurrence of the givenT> , provided by the KtSetExtension extensionelement
. -
minWith(
Comparator< T> comparator) → T? -
Available on KtIterable<
Returns the first element having the smallest value according to the providedT> , provided by the KtIterableExtensions extensioncomparator
ornull
if there are no elements. -
none(
[bool predicate(T)?]) → bool -
Available on KtIterable<
ReturnsT> , provided by the KtIterableExtensions extensiontrue
if the collection has no elements or no elements match the givenpredicate
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onEach(
void action(T item)) → KtIterable< T> -
Available on KtIterable<
Performs the givenT> , provided by the ChainableKtIterableExtensions extensionaction
on each element. Use with cascade syntax to return self. -
onEach(
void action(T item)) → KtSet< T> -
Available on KtSet<
Performs the givenT> , provided by the ChainableKtSetExtensions extensionaction
on each element. Use with cascade syntax to return self. -
onEachIndexed(
void action(int index, T item)) → KtSet< T> -
Available on KtSet<
Performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards.T> , provided by the ChainableKtSetExtensions extension -
onEachIndexed(
void action(int index, T item)) → KtIterable< T> -
Available on KtIterable<
Performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards.T> , provided by the ChainableKtIterableExtensions extension -
orEmpty(
) → KtSet< T> -
Available on KtSet<
Returns this KtSet if it's notT> ?, provided by the NullableKtSetExtensions extensionnull
and the empty set otherwise. -
orEmpty(
) → KtCollection< T> -
Available on KtCollection<
Returns this KtCollection if it's notT> ?, provided by the NullableKtCollectionExtensions extensionnull
and the empty list otherwise. -
partition(
bool predicate(T)) → KtPair< KtList< T> , KtList<T> > -
Available on KtIterable<
Splits the original collection into pair of lists, where first list contains elements for whichT> , provided by the KtIterableExtensions extensionpredicate
yieldedtrue
, while second list contains elements for whichpredicate
yieldedfalse
. -
plus(
KtIterable< T> elements) → KtSet<T> -
Available on KtSet<
Returns a set containing all elements of the original collection and then all elements of the givenT> , provided by the KtSetExtension extensionelements
collection. -
plus(
KtIterable< T> elements) → KtList<T> -
Available on KtIterable<
Returns a list containing all elements of the original collection and then all elements of the givenT> , provided by the KtIterableExtensions extensionelements
collection. -
plusElement(
T element) → KtSet< T> -
Available on KtSet<
Returns a set containing all elements of the original collection and then the givenT> , provided by the KtSetExtension extensionelement
. -
plusElement(
T element) → KtList< T> -
Available on KtIterable<
Returns a list containing all elements of the original collection and then the givenT> , provided by the KtIterableExtensions extensionelement
. -
random(
[Random? random]) → T -
Available on KtCollection<
Returns a random element from this collection.T> , provided by the KtCollectionExtensions extension -
randomOrNull(
[Random? random]) → T? -
Available on KtCollection<
Returns a random element from this collection.T> , provided by the KtCollectionExtensions extension -
reduce<
S> (S operation(S acc, T)) → S -
Available on KtIterable<
Accumulates value starting with the first element and applyingT> , provided by the KtIterableExtensions extensionoperation
from left to right to current accumulator value and each element. -
reduceIndexed<
S> (S operation(int index, S acc, T)) → S -
Available on KtIterable<
Accumulates value starting with the first element and applyingT> , provided by the KtIterableExtensions extensionoperation
from left to right to current accumulator value and each element with its index in the original collection. @paramoperation
function that takes the index of an element, current accumulator value and the element itself and calculates the next accumulator value. -
reduceIndexedOrNull<
S> (S operation(int index, S acc, T)) → S? -
Available on KtIterable<
Accumulates value starting with the first element and applyingT> , provided by the KtIterableExtensions extensionoperation
from left to right to current accumulator value and each element with its index in the original collection. -
reduceOrNull<
S> (S operation(S acc, T)) → S? -
Available on KtIterable<
Accumulates value starting with the first element and applyingT> , provided by the KtIterableExtensions extensionoperation
from left to right to current accumulator value and each element. -
requireNoNulls(
) → KtIterable< T> -
Available on KtIterable<
Returns an original collection containing all the non-T?> , provided by the RequireNoNullsKtIterableExtension extensionnull
elements, throwing an ArgumentError if there are anynull
elements. -
reversed(
) → KtList< T> -
Available on KtIterable<
Returns a list with elements in reversed order.T> , provided by the KtIterableExtensions extension -
runningReduce<
S> (S operation(S acc, T)) → KtList< S> -
Available on KtIterable<
Returns a list containing successive accumulation values generated by applyingT> , provided by the KtIterableExtensions extensionoperation
from left to right to each element and current accumulator value that starts with the first element of this collection. -
runningReduceIndexed<
S> (S operation(int index, S acc, T)) → KtList< S> -
Available on KtIterable<
Returns a list containing successive accumulation values generated by applyingT> , provided by the KtIterableExtensions extensionoperation
from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection. -
shuffled(
[Random? random]) → KtList< T> -
Available on KtIterable<
Returns a new list with the elements of this list randomly shuffled.T> , provided by the KtIterableExtensions extension -
single(
[bool predicate(T)?]) → T -
Available on KtIterable<
Returns the single element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
, or throws an exception if the list is empty or has more than one element. -
singleOrNull(
[bool predicate(T)?]) → T? -
Available on KtIterable<
Returns the single element matching the givenT> , provided by the KtIterableExtensions extensionpredicate
, ornull
if element was not found or more than one element was found. -
sorted(
) → KtList< T> -
Available on KtIterable<
Returns a list of all elements sorted according to their natural sort order.T> , provided by the KtIterableExtensions extension -
sortedBy<
R extends Comparable> (R selector(T)) → KtList< T> -
Available on KtIterable<
Returns a list of all elements sorted according to natural sort order of the value returned by specifiedT> , provided by the KtIterableExtensions extensionselector
function. -
sortedByDescending<
R extends Comparable> (R selector(T)) → KtList< T> -
Available on KtIterable<
Returns a list of all elements sorted descending according to natural sort order of the value returned by specifiedT> , provided by the KtIterableExtensions extensionselector
function. -
sortedDescending(
) → KtList< T> -
Available on KtIterable<
Returns a list of all elements sorted descending according to their natural sort order.T> , provided by the KtIterableExtensions extension -
sortedWith(
Comparator< T> comparator) → KtList<T> -
Available on KtIterable<
Returns a list of all elements sorted according to the specifiedT> , provided by the KtIterableExtensions extensioncomparator
. -
subtract(
KtIterable< T> other) → KtSet<T> -
Available on KtIterable<
Returns a set containing all elements that are contained by this collection and not contained by the specified collection.T> , provided by the KtIterableExtensions extension -
sum(
) → int -
Available on KtIterable<
Returns the sum of all elements in the collection.int> , provided by the KtIntIterableExtension extension -
sum(
) → double -
Available on KtIterable<
Returns the sum of all elements in the collection.double> , provided by the KtDoubleIterableExtension extension -
sumBy<
R extends num> (R selector(T)) → R -
Available on KtIterable<
Returns the sum of all values produced byT> , provided by the KtIterableExtensions extensionselector
function applied to each element in the collection. -
sumByDouble(
double selector(T)) → double -
Available on KtIterable<
Returns the sum of all values produced byT> , provided by the KtIterableExtensions extensionselector
function applied to each element in the collection. -
sumOf<
R extends num> (R selector(T)) → R -
Available on KtCollection<
Returns the sum of all elements in this collection.T> , provided by the KtCollectionExtensions extension -
take(
int n) → KtList< T> -
Available on KtIterable<
Returns a list containing firstT> , provided by the KtIterableExtensions extensionn
elements. -
takeWhile(
bool predicate(T)) → KtList< T> -
Available on KtIterable<
Returns a list containing first elements satisfying the givenT> , provided by the KtIterableExtensions extensionpredicate
. -
toCollection<
C extends KtMutableCollection> (C destination) → C -
Available on KtIterable<
Appends all elements to the givenT> , provided by the KtIterableExtensions extensiondestination
collection. -
toHashSet(
) → KtMutableSet< T> -
Available on KtIterable<
Returns a HashSet of all elements.T> , provided by the KtIterableExtensions extension -
toList(
) → KtList< T> -
Available on KtIterable<
Returns a KtList containing all elements.T> , provided by the KtIterableExtensions extension -
toMutableList(
) → KtMutableList< T> -
Available on KtCollection<
Returns a KtMutableList filled with all elements of this collection.T> , provided by the KtCollectionExtensions extension -
toMutableList(
) → KtMutableList< T> -
Available on KtIterable<
Returns a KtMutableList filled with all elements of this collection.T> , provided by the KtIterableExtensions extension -
toMutableSet(
) → KtMutableSet< T> -
Available on KtIterable<
Returns a mutable set containing all distinct elements from the given collection.T> , provided by the KtIterableExtensions extension -
toSet(
) → KtSet< T> -
Available on KtIterable<
Returns a KtSet of all elements.T> , provided by the KtIterableExtensions extension -
toString(
) → String -
A string representation of this object.
inherited
-
union(
KtIterable< T> other) → KtSet<T> -
Available on KtIterable<
Returns a set containing all distinct elements from both collections.T> , provided by the KtIterableExtensions extension -
unzip(
) → KtPair< KtList< T> , KtList<R> > -
Available on KtIterable<
Returns a pair of lists, where first list is built from the first values of each pair from this collection, second list is built from the second values of each pair from this collection.KtPair< , provided by the UnzipKtIterableExtensions extensionT, R> > -
windowed(
int size, {int step = 1, bool partialWindows = false}) → KtList< KtList< T> > -
Available on KtIterable<
Returns a list of snapshots of the window of the givenT> , provided by the KtIterableExtensions extensionsize
sliding along this collection with the givenstep
, where each snapshot is a list. -
windowedTransform<
R> (int size, R transform(KtList< T> ), {int step = 1, bool partialWindows = false}) → KtList<R> -
Available on KtIterable<
Returns a list of results of applying the givenT> , provided by the KtIterableExtensions extensiontransform
function to an each list representing a view over the window of the givensize
sliding along this collection with the givenstep
. -
zip<
R> (KtIterable< R> other) → KtList<KtPair< T, R> > -
Available on KtIterable<
Returns a list of pairs built from the elements ofT> , provided by the KtIterableExtensions extensionthis
collection andother
collection with the same index. The returned list has length of the shortest collection. -
zipTransform<
R, V> (KtIterable< R> other, V transform(T a, R b)) → KtList<V> -
Available on KtIterable<
Returns a list of values built from the elements ofT> , provided by the KtIterableExtensions extensionthis
collection and theother
collection with the same index using the providedtransform
function applied to each pair of elements. The returned list has length of the shortest collection. -
zipWithNext(
) → KtList< KtPair< T, T> > -
Available on KtIterable<
Returns a list of pairs of each two adjacent elements in this collection.T> , provided by the KtIterableExtensions extension -
zipWithNextTransform<
R> (R transform(T a, T b)) → KtList< R> -
Available on KtIterable<
Returns a list containing the results of applying the givenT> , provided by the KtIterableExtensions extensiontransform
function to an each pair of two adjacent elements in this collection.
Operators
-
operator +(
KtIterable< T> elements) → KtList<T> -
Available on KtIterable<
Returns a list containing all elements of the original collection and then all elements of the givenT> , provided by the KtIterableExtensions extensionelements
collection. -
operator +(
KtIterable< T> elements) → KtSet<T> -
Available on KtSet<
Returns a set containing all elements of the original collection and then all elements of the givenT> , provided by the KtSetExtension extensionelements
collection. -
operator -(
KtIterable< T> elements) → KtList<T> -
Available on KtIterable<
Returns a list containing all elements of the original collection except the elements contained in the givenT> , provided by the KtIterableExtensions extensionelements
collection. -
operator -(
KtIterable< T> elements) → KtSet<T> -
Available on KtSet<
Returns a set containing all elements of the original collection except the elements contained in the givenT> , provided by the KtSetExtension extensionelements
collection. -
operator ==(
Object other) → bool -
The equality operator.
inherited