Multiset<E> class
A generalized Set (or Bag) in which members are allowed to appear more than once.
- Inheritance
-
- Object
- IterableBase<
E> - Multiset
- Available extensions
- BiMapOnIterableExtension
- BitListExtension
- ChunkedIterableExtension
- CloseMatchesOnIterable
- CloseMatchesOnStringIterable
- CombinationsIterableExtension
- CompoundIterableComparator
- CountIterableExtension
- DeepFlattenIterableExtension
- EnumByName
- FlatMapIterableExtension
- FlattenIterableExtension
- FutureIterable
- GcdBigIntIterableExtension
- GcdIntegerIterableExtension
- GroupIterableExtension
- IndexedIterableExtension
- IndicesIterableExtension
- IterableExtensions
- LcmBigIntIterableExtension
- LcmIntegerIterableExtension
- ListMultimapOnIterableExtension
- MultisetExtension
- NullableIterableExtensions
- OperatorsIterableExtension
- PairwiseIterableExtension
- PartitionIterableExtension
- PermutationIterableExtension
- PolynomialIterableExtension
- PowerSetIterableExtension
- ProductIterableExtension
- RandomIterableExtension
- RepeatIterableExtension
- SeparatedIterableExtension
- SequencePrinterIterableExtension
- SetMultimapOnIterableExtension
- SortedListIterableExtension
- ToMapIterableExtension
- UniqueIterableExtension
- WindowIterableExtension
- ZipIterableExtension
Constructors
- Multiset()
-
Creates an empty Multiset.
factory
-
Multiset.from(Iterable<
E> other) -
Creates a Multiset that contains all elements of
other
.factory -
Multiset.fromIterable(Iterable<
Object?> iterable, {E key(Object? element)?, int count(Object? element)?}) -
Creates a Multiset where the elements and their occurrence count is
computed from an
iterable
.factory - Multiset.identity()
-
Creates an empty identity Multiset.
factory
-
Multiset.of(Iterable<
E> other) -
Creates a Multiset that contains all elements of
other
.factory
Properties
-
counts
→ Iterable<
int> -
Returns an iterable over the counts of the distinct elements of the
receiver.
no setter
-
distinct
→ Iterable<
E> -
Returns an iterable over the distinct elements of the receiver.
no setter
-
elementCounts
→ Iterable<
int> -
Returns an iterable over the counts of the distinct elements of the
receiver.
no setter
-
elementSet
→ Iterable<
E> -
Returns an iterable over the distinct elements of the receiver.
no setter
-
entrySet
→ Iterable<
MapEntry< E, int> > -
Returns an iterable over the distinct elements
key
and their respective countvalue
.no setter - first → E
-
The first element.
no setterinherited
- firstOrNull → T?
-
Available on Iterable<
The first element of this iterator, orT> , provided by the IterableExtensions extensionnull
if the iterable is empty.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
indexed
→ Iterable<
(int, T)> -
Available on Iterable<
Pairs of elements of the indices and elements of this iterable.T> , provided by the IterableExtensions extensionno setter - isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
E> -
Iterator over the repeated elements of the receiver.
no setteroverride
- last → E
-
The last element.
no setterinherited
- lastOrNull → T?
-
Available on Iterable<
The last element of this iterable, orT> , provided by the IterableExtensions extensionnull
if the iterable is empty.no setter - length → int
-
Returns the total number of elements in the receiver.
no setteroverride
-
nonNulls
→ Iterable<
T> -
Available on Iterable<
The non-T?> , provided by the NullableIterableExtensions extensionnull
elements of this iterable.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → E
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
- singleOrNull → T?
-
Available on Iterable<
The single element of this iterator, orT> , provided by the IterableExtensions extensionnull
.no setter -
wait
→ Future<
List< T> > -
Available on Iterable<
Waits for futures in parallel.Future< , provided by the FutureIterable extensionT> >no setter
Methods
-
add(
E element, [int occurrences = 1]) → void -
Adds
element
to the receiveroccurrences
number of times. -
addAll(
Iterable< E> elements) → void -
Adds all of
elements
to the receiver. -
any(
bool test(E element)) → bool -
Checks whether any element of this iterable satisfies
test
.inherited -
asMap(
) → Map< E, int> - Returns an unmodifiable view of the underlying data in a Map with the elements as the key and their counts as the value.
-
asNameMap(
) → Map< String, T> -
Available on Iterable<
Creates a map from the names of enum values to the values.T> , provided by the EnumByName extension -
atRandom(
{Random? random, E orElse()?}) → E -
Available on Iterable<
Returns a random element from this Iterable.E> , provided by the RandomIterableExtension extension -
byName(
String name) → T -
Available on Iterable<
Finds the enum value in this list with nameT> , provided by the EnumByName extensionname
. -
cast<
R> () → Iterable< R> -
A view of this iterable as an iterable of
R
instances.inherited -
chunked(
int size) → Iterable< List< E> > -
Available on Iterable<
Divides this Iterable into sub-lists of a givenE> , provided by the ChunkedIterableExtension extensionsize
. The final list might be smaller or equal to the desired size. -
chunkedWithPadding(
int size, E padding) → Iterable< Iterable< E> > -
Available on Iterable<
Divides this Iterable into sub-lists of a givenE> , provided by the ChunkedIterableExtension extensionsize
. The final list is expanded with the providedpadding
, ornull
. -
clear(
) → void - Removes all elements from the receiver.
-
closeMatches(
String target, {int count = 3, double cutoff = 0.6}) → Iterable< String> -
Available on Iterable<
Returns a list of the best "good enough" matches of a list of strings.String> , provided by the CloseMatchesOnStringIterable extension -
closeMatches(
Iterable< T> target, {int count = 3, double cutoff = 0.6}) → Iterable<Iterable< T> > -
Available on Iterable<
Returns a list of the best "good enough" matches.Iterable< , provided by the CloseMatchesOnIterable extensionT> > -
combinations(
int count, {bool repetitions = false}) → Iterable< List< E> > -
Available on Iterable<
Returns an iterable over the combinations of this Iterable of lengthE> , provided by the CombinationsIterableExtension extensioncount
. The combinations are emitted in lexicographical order based on the input. -
combine(
Iterable< E> other, int callback(E element, int a, int b)) → Multiset<E> -
Returns a new Multiset by evaluating
callback
element-wise for each distinct element ofthis
andother
. -
contains(
Object? element) → bool -
Returns
true
ifelement
is in the receiver.override -
containsAll(
Iterable< Object?> other) → bool -
Returns
true
if all elements ofother
are contained in the receiver. -
count(
bool predicate(E element)) → int -
Available on Iterable<
Returns the number of timeE> , provided by the CountIterableExtension extensionpredicate
evaluates to true. -
deepFlatten<
E> () → Iterable< E> -
Available on Iterable, provided by the DeepFlattenIterableExtension extension
Flattens arbitrarily nested Iterables with elements of typeE
. Throws an ArgumentError when encountering an value of an unexpected type. -
difference(
Iterable< Object?> other) → Multiset<E> -
Returns a new Multiset with all the elements of the receiver that are
not in
other
. -
elementAt(
int index) → E -
Returns the
index
th element.inherited -
elementAtOrNull(
int index) → T? -
Available on Iterable<
The element at positionT> , provided by the IterableExtensions extensionindex
of this iterable, ornull
. -
every(
bool test(E element)) → bool -
Checks whether every element of this iterable satisfies
test
.inherited -
expand<
T> (Iterable< T> toElements(E element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(E element), {E orElse()?}) → E -
The first element that satisfies the given predicate
test
.inherited -
flatMap<
T> (Iterable< T> callback(E element)) → Iterable<T> -
Available on Iterable<
Maps each element of this Iterable using a mapping function to zero or more elements, then flattens the result into a continuous iterable.E> , provided by the FlatMapIterableExtension extension -
flatten(
) → Iterable< E> -
Available on Iterable<
Flattens an Iterable of Iterables to a flattened Iterable.Iterable< , provided by the FlattenIterableExtension extensionE> > -
fold<
T> (T initialValue, T combine(T previousValue, E element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< E> other) → Iterable<E> -
Creates the lazy concatenation of this iterable and
other
.inherited -
forEach(
void action(E element)) → void -
Invokes
action
on each element of this iterable in iteration order.inherited -
gcd(
) → BigInt -
Available on Iterable<
Returns the greatest common divisor (GCD) of the values in this Iterable. This is the largest positive integer that divides all numbers.BigInt> , provided by the GcdBigIntIterableExtension extension -
gcd(
) → int -
Available on Iterable<
Returns the greatest common divisor (GCD) of the values in this Iterable. This is the largest positive integer that divides all numbers.int> , provided by the GcdIntegerIterableExtension extension -
groupBy<
K> ([K key(V element)?]) → Iterable< Group< K, V> > -
Available on Iterable<
Groups consecutive keys of this Iterable.V> , provided by the GroupIterableExtension extension -
indexed(
{int start = 0, int step = 1, int? offset}) → Iterable< Indexed< E> > -
Available on Iterable<
Returns a iterable that combines the index and value of this Iterable.E> , provided by the IndexedIterableExtension extension -
indices(
{int step = 1}) → Range< int> -
Available on Iterable<
Returns a Range of the indices of this iterable that can be accessed with theObject?> , provided by the IndicesIterableExtension extension[]
operator. -
intersection(
Iterable< Object?> other) → Multiset<E> -
Returns a new Multiset with the elements that are in the receiver as
well as those in
other
. -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
largest(
int count, {Comparator< E> ? comparator}) → List<E> -
Available on Iterable<
Returns a list of theE> , provided by the OperatorsIterableExtension extensioncount
largest elements of this Iterable. The elements need to be Comparable, unless a customcomparator
is provided. -
lastWhere(
bool test(E element), {E orElse()?}) → E -
The last element that satisfies the given predicate
test
.inherited -
lcm(
) → BigInt -
Available on Iterable<
Returns the least common multiple (LCM) of the values in this Iterable. This is the smallest positive integer that is divisible by all numbers.BigInt> , provided by the LcmBigIntIterableExtension extension -
lcm(
) → int -
Available on Iterable<
Returns the least common multiple (LCM) of the values in this Iterable. This is the smallest positive integer that is divisible by all numbers.int> , provided by the LcmIntegerIterableExtension extension -
map<
T> (T toElement(E e)) → Iterable< T> -
The current elements of this iterable modified by
toElement
.inherited -
max(
{Comparator< E> ? comparator, E orElse()?}) → E -
Available on Iterable<
Returns the maximum of this Iterable. The elements need to be Comparable, unless a customE> , provided by the OperatorsIterableExtension extensioncomparator
is provided. -
min(
{Comparator< E> ? comparator, E orElse()?}) → E -
Available on Iterable<
Returns the minimum of this Iterable. The elements need to be Comparable, unless a customE> , provided by the OperatorsIterableExtension extensioncomparator
is provided. -
minMax(
{Comparator< E> ? comparator, ({E max, E min}) orElse()?}) → ({E max, E min}) -
Available on Iterable<
Returns the minimum and maximum of this Iterable at once. The elements need to be Comparable, unless a customE> , provided by the OperatorsIterableExtension extensioncomparator
is provided. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
occurrences(
E element) → int -
Available on Iterable<
Returns the number of timesE> , provided by the CountIterableExtension extensionelement
appears in the iterable. -
pairwise(
) → Iterable< (E, E)> -
Available on Iterable<
An iterable over the successive overlapping pairs of this iterable.E> , provided by the PairwiseIterableExtension extension -
partition(
bool test(E element)) → ({List< E> falsey, List<E> truthy}) -
Available on Iterable<
Splits this iterable into two lists: theE> , provided by the PartitionIterableExtension extensiontruthy
list where thetest
predicate istrue
and thefalsey
list where thetest
predicate isfalse
. -
permutations(
[int? count]) → Iterable< List< E> > -
Available on Iterable<
Returns an iterable over the permutations of this Iterable of lengthE> , provided by the PermutationIterableExtension extensioncount
. If nocount
is specified all full-length permutations are generated. The permutations are emitted in lexicographical order based on the input. -
polynomial(
[num x = 10]) → num -
Available on Iterable<
Evaluates the polynomial described by this Iterables coefficients and the valuenum> , provided by the PolynomialIterableExtension extensionx
. -
powerSet(
) → Iterable< List< E> > -
Available on Iterable<
Returns all subsets of this iterable including the empty set and the complete set itself. The power-set has 2^n elements, if the iterable has length n.E> , provided by the PowerSetIterableExtension extension -
product(
{int repeat = 1}) → Iterable< List< E> > -
Available on Iterable<
Returns an iterable over the cross product of this Iterable.Iterable< , provided by the ProductIterableExtension extensionE> > -
reduce(
E combine(E value, E element)) → E -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
remove(
Object? element, [int occurrences = 1]) → void -
Removes
element
from the receiveroccurrences
number of times. -
removeAll(
Iterable< Object?> elements) → void -
Removes each element of
elements
from the receiver. -
repeat(
{int? count}) → Iterable< E> -
Available on Iterable<
Returns an infinite iterable with the elements of this iterable. IfE> , provided by the RepeatIterableExtension extensioncount
is provided the resulting iterator is limited tocount
repetitions. -
separatedBy(
Builder< E> separator, {Builder<E> ? before, Builder<E> ? after}) → Iterable<E> -
Available on Iterable<
Returns an Iterable where every element is separated by an element built by aE> , provided by the SeparatedIterableExtension extensionseparator
builder. Optionally specifiedbefore
andafter
builders can provide an element at the beginning or the end of the non-empty iterable. -
singleWhere(
bool test(E element), {E orElse()?}) → E -
The single element that satisfies
test
.inherited -
skip(
int count) → Iterable< E> -
Creates an Iterable that provides all but the first
count
elements.inherited -
skipWhile(
bool test(E value)) → Iterable< E> -
Creates an
Iterable
that skips leading elements whiletest
is satisfied.inherited -
smallest(
int count, {Comparator< E> ? comparator}) → List<E> -
Available on Iterable<
Returns a list of theE> , provided by the OperatorsIterableExtension extensioncount
smallest elements of this Iterable. The elements need to be Comparable, unless a customcomparator
is provided. -
take(
int count) → Iterable< E> -
Creates a lazy iterable of the
count
first elements of this iterable.inherited -
takeWhile(
bool test(E value)) → Iterable< E> -
Creates a lazy iterable of the leading elements satisfying
test
.inherited -
toBiMap<
K, V> ({K key(E element)?, V value(E element)?}) → BiMap< K, V> -
Available on Iterable<
Converts this Iterable to a BiMap.E> , provided by the BiMapOnIterableExtension extension -
toBitList(
{bool growable = false}) → BitList -
Available on Iterable<
Converts this Iterable to a space-efficient BitList.bool> , provided by the BitListExtension extension -
toComparator(
) → Comparator< T> -
Available on Iterable<
Returns a Comparator that tries each of the comparators in this iterable in order and returns the first result that doesn't end up in a tie.Comparator< , provided by the CompoundIterableComparator extensionT> > -
toList(
{bool growable = true}) → List< E> -
Creates a List containing the elements of this Iterable.
inherited
-
toListMultimap<
K, V> ({K key(E element)?, V value(E element)?, Map< K, List< ? map, Factory<V> >List< ? factory}) → ListMultimap<V> >K, V> -
Available on Iterable<
Converts this Iterable to a ListMultimap.E> , provided by the ListMultimapOnIterableExtension extension -
toMap<
K, V> ({K key(E element)?, V value(E element)?}) → Map< K, V> -
Available on Iterable<
Returns an Map from an Iterable.E> , provided by the ToMapIterableExtension extension -
toMultiset(
) → Multiset< T> -
Available on Iterable<
T> , provided by the MultisetExtension extension -
toPrinter(
) → Printer< T> -
Available on Iterable<
Constructs a sequence of printers.Printer< , provided by the SequencePrinterIterableExtension extensionT> > -
toSet(
) → Set< E> -
Creates a Set containing the same elements as this iterable.
inherited
-
toSetMultimap<
K, V> ({K key(E element)?, V value(E element)?, Map< K, Set< ? map, Factory<V> >Set< ? factory}) → SetMultimap<V> >K, V> -
Available on Iterable<
Converts this Iterable to a SetMultimap.E> , provided by the SetMultimapOnIterableExtension extension -
toSortedList(
{Comparator< E> ? comparator, bool growable = true}) → SortedList<E> -
Available on Iterable<
Converts this Iterable to a SortedList.E> , provided by the SortedListIterableExtension extension -
toString(
) → String -
Returns a string representation of (some of) the elements of
this
.inherited -
union(
Iterable< E> other) → Multiset<E> -
Returns a new Multiset with all the elements of the receiver and those
in
other
. -
unique(
{Set< E> factory()?, bool equals(E e1, E e2)?, int hashCode(E e)?}) → Iterable<E> -
Available on Iterable<
Returns a lazy iterable that filters out duplicates from this Iterator.E> , provided by the UniqueIterableExtension extension -
where(
bool test(E element)) → Iterable< E> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T
.inherited -
window(
int size, {int step = 1, bool includePartial = false}) → Iterable< List< E> > -
Available on Iterable<
Sliding window of givenE> , provided by the WindowIterableExtension extensionsize
over this Iterable. -
zip(
) → Iterable< List< E> > -
Available on Iterable<
Combines the first, second, third, ... elements of each Iterable into a new list. The resulting iterable has the length of the shortest input iterable.Iterable< , provided by the ZipIterableExtension extensionE> > -
zipPartial(
) → Iterable< List< E?> > -
Available on Iterable<
Combines the first, second, third, ... elements of each Iterable into a new list. The resulting iterable has the length of the longest input iterable, missing values are padded withIterable< , provided by the ZipIterableExtension extensionE> >null
. -
zipPartialWith(
E padding) → Iterable< List< E> > -
Available on Iterable<
Combines the first, second, third, ... elements of each Iterable into a new list. The resulting iterable has the length of the longest input iterable, missing values are padded withIterable< , provided by the ZipIterableExtension extensionE> >padding
.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
Object? element) → int -
Gets the number of occurrences of an
element
. -
operator []=(
E element, int occurrences) → void -
Sets the number of
occurrences
of anelement
.