FicIterableExtension<T> extension

on

Methods

anyIs(T value) bool
Returns true if any item is equal to value.
deepEquals(Iterable? other, {bool ignoreOrder = false}) bool
Compare all items, in order or not, according to ignoreOrder, using operator ==. Return true if they are all the same, in the same order.
deepEqualsByIdentity(Iterable? other, {bool ignoreOrder = false}) bool
Return true if they are all the same, in the same order. Compare all items, in order or not, according to ignoreOrder, using identical. Return true if they are all the same, in the same order.
everyIs(T value) bool
Returns true if all items are equal to value.
findDuplicates() Set<T>
Finds duplicates and then returns a Set with the duplicated elements. If there are no duplicates, an empty Set is returned.
isFirst(T item) bool
Return true if the given item is the same (by identity) as the first iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you have the first item. For example:
isLast(T item) bool
Return true if the given item is the same (by identity) as the last iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you have the last item. For example:
isNotFirst(T item) bool
Return true if the given item is NOT the same (by identity) as the first iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you don't have the first item. For example:
isNotLast(T item) bool
Return true if the given item is NOT the same (by identity) as the last iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you don't have the last item. For example:
restrict(T? item, {required T orElse}) → T
Restricts some item to one of those present in this iterable.
sortedLike(Iterable ordering) List<T>
Returns a list, sorted according to the order specified by the ordering iterable. Items which don't appear in ordering will be included in the end, in their original order. Items of ordering which are not found in the original list are ignored.
sortedReversed([Comparator<T>? compare]) List<T>
Creates a reversed sorted list of the elements of the iterable.
toIList([ConfigList? config]) IList<T>
Creates an immutable list (IList) from the iterable.
toISet([ConfigSet? config]) ISet<T>
Creates an immutable set (ISet) from the iterable.
updateById(Iterable<T> newItems, dynamic id(T item)) List<T>
Returns a new list where newItems are added or updated, by their id (and the id is a function of the item), like so:
whereNoDuplicates({dynamic by(T item)?, bool removeNulls = false}) Iterable<T>
Removes all duplicates, leaving only the distinct items. Optionally, you can provide an by function to compare the items.