SortedMap<K extends Ordered<Object> , V extends Object?> class
base
A Map of key–value pairs stored as sorted entries.
The implementation of the SortedMap class is based on TreeSet
. The map's
keys are compared using a Comparator function provided in the constructor.
If the Comparator is omitted, the keys are compared using the
Comparable.compareTo method.
An example of typical usage:
var weekDays = SortedMap<int, String>();
weekDays.insert(7, "diēs Sāturnī");
weekDays.insert(1, "diēs Sōlis");
print(weekDays.map((var e) => "${e.key} => ${e.value}"));
// (1 => diēs Sōlis, 7 => diēs Sāturnī)
weekDays[1]!.value = "duminică";
weekDays.erase(7);
weekDays.insert(7, "sâmbătă");
print(weekDays.map((var e) => "${e.key} => ${e.value}"));
// (1 => duminică, 7 => sâmbătă)
- Inheritance
-
- Object
- IterableBase<
SortedMapEntry< K, V> > - SortedMap
- Mixed-in types
-
- SetMixin<
SortedMapEntry< K, V> >
- SetMixin<
Constructors
-
SortedMap.new({Comparator<
K> ? comparator}) - Creates an empty SortedMap.
Properties
-
first
→ SortedMapEntry<
K, V> -
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ TreeIterator<
SortedMapEntry< K, V> > -
A
TreeIterator
that iterates over the entries of this map.no setteroverride -
last
→ SortedMapEntry<
K, V> -
The last entry in this map.
no setteroverride
- length → int
-
The number of entries in this map.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
single
→ SortedMapEntry<
K, V> -
Checks that this iterable has only one element, and returns that element.
no setterinherited
Methods
-
add(
SortedMapEntry< K, V> entry) → bool -
Adds
entry
to this map.override -
addAll(
Iterable< SortedMapEntry< elements) → voidK, V> > -
Adds all
elements
to this set.inherited -
any(
bool test(SortedMapEntry< K, V> element)) → bool -
Checks whether any element of this iterable satisfies
test
.inherited -
cast<
R> () → Set< R> -
Provides a view of this set as a set of
R
instances.inherited -
clear(
) → void -
Removes all entries from this map.
override
-
contains(
Object? element) → bool -
Whether
element
is a SortedMapEntry pair contained in this map.override -
containsAll(
Iterable< Object?> other) → bool -
Whether this set contains all the elements of
other
.inherited -
difference(
Set< Object?> other) → Set<SortedMapEntry< K, V> > -
Creates a new set with the elements of this that are not in
other
.inherited -
elementAt(
int index) → SortedMapEntry< K, V> -
Returns the
index
th element.inherited -
erase(
K key) → bool -
Uses
key
to remove an entry from this map. -
every(
bool f(SortedMapEntry< K, V> element)) → bool -
Checks whether every element of this iterable satisfies
test
.inherited -
expand<
T> (Iterable< T> f(SortedMapEntry<K, V> element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(SortedMapEntry< K, V> value), {SortedMapEntry<K, V> orElse()?}) → SortedMapEntry<K, V> -
The first element that satisfies the given predicate
test
.inherited -
fold<
T> (T initialValue, T combine(T previousValue, SortedMapEntry< K, V> element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< SortedMapEntry< other) → Iterable<K, V> >SortedMapEntry< K, V> > -
Creates the lazy concatenation of this iterable and
other
.inherited -
forEach(
void f(SortedMapEntry< K, V> element)) → void -
Invokes
action
on each element of this iterable in iteration order.inherited -
fromIterator(
K anchor, {bool reversed = false, bool inclusive = true}) → TreeIterator< SortedMapEntry< K, V> > -
Returns a
TreeIterator
for the map entries, starting at theanchor
key. -
insert(
K key, V value) → bool - Adds a key–value pair as an entry to this map.
-
intersection(
Set< Object?> other) → Set<SortedMapEntry< K, V> > -
Creates a new set which is the intersection between this set and
other
.inherited -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(SortedMapEntry< K, V> value), {SortedMapEntry<K, V> orElse()?}) → SortedMapEntry<K, V> -
The last element that satisfies the given predicate
test
.inherited -
lookup(
Object? element) → SortedMapEntry< K, V> ? -
If
element
is a SortedMapEntry, its key is used to find an entry in this map.override -
map<
T> (T f(SortedMapEntry< K, V> element)) → Iterable<T> -
The current elements of this iterable modified by
toElement
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reduce(
SortedMapEntry< K, V> combine(SortedMapEntry<K, V> value, SortedMapEntry<K, V> element)) → SortedMapEntry<K, V> -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
remove(
Object? element) → bool -
If
element
is a SortedMapEntry, its key is used to remove an entry from this map.override -
removeAll(
Iterable< Object?> elements) → void -
Removes each element of
elements
from this set.inherited -
removeWhere(
bool test(SortedMapEntry< K, V> element)) → void -
Removes all elements of this set that satisfy
test
.inherited -
retainAll(
Iterable< Object?> elements) → void -
Removes all elements of this set that are not elements in
elements
.inherited -
retainWhere(
bool test(SortedMapEntry< K, V> element)) → void -
Removes all elements of this set that fail to satisfy
test
.inherited -
singleWhere(
bool test(SortedMapEntry< K, V> value), {SortedMapEntry<K, V> orElse()?}) → SortedMapEntry<K, V> -
The single element that satisfies
test
.inherited -
skip(
int n) → Iterable< SortedMapEntry< K, V> > -
Creates an Iterable that provides all but the first
count
elements.inherited -
skipWhile(
bool test(SortedMapEntry< K, V> value)) → Iterable<SortedMapEntry< K, V> > -
Creates an
Iterable
that skips leading elements whiletest
is satisfied.inherited -
take(
int n) → Iterable< SortedMapEntry< K, V> > -
Creates a lazy iterable of the
count
first elements of this iterable.inherited -
takeWhile(
bool test(SortedMapEntry< K, V> value)) → Iterable<SortedMapEntry< K, V> > -
Creates a lazy iterable of the leading elements satisfying
test
.inherited -
toList(
{bool growable = true}) → List< SortedMapEntry< K, V> > -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< SortedMapEntry< K, V> > -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
union(
Set< SortedMapEntry< other) → Set<K, V> >SortedMapEntry< K, V> > -
Creates a new set which contains all the elements of this set and
other
.inherited -
where(
bool f(SortedMapEntry< K, V> element)) → Iterable<SortedMapEntry< K, V> > -
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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
K key) → SortedMapEntry< K, V> ? -
Uses
key
to locate an entry in this map.