Pair<T1, T2> class
A class that stores a pair of values.
In the C++ STL, std::pair is defined in <utility>.
It provides a way to store two heterogeneous objects as a single unit.
- Available extensions
Constructors
- Pair(T1 first, T2 second)
-
Creates a Pair grouping the
firstandsecondvalues dynamically. -
Pair.fromMapEntry(MapEntry<
T1, T2> entry) - Creates a Pair from a MapEntry.
- Pair.fromRecord((T1, T2) record)
- Creates a Pair from a modern Dart 3 Record.
Properties
- first ↔ T1
-
The first element of the pair.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setteroverride
- record → (T1, T2)
-
Returns the pair as a modern Dart 3 Record for easy destructuring.
Example:
var (a, b) = myPair.record;no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second ↔ T2
-
The second element of the pair.
getter/setter pair
Methods
-
clone(
) → Pair< T1, T2> - Creates a shallow clone of the Pair.
-
compareTo(
Pair< T1, T2> other) → int -
Available on Pair<
Compares this pair lexicographically withT1, T2> , provided by the ComparablePair extensionother. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
swap(
Pair< T1, T2> other) → void -
Exchanges the contents of this pair with those of
other. -
toList(
) → List - Returns the elements as a standard Dart List.
-
toMapEntry(
) → MapEntry< T1, T2> - Returns the pair as a MapEntry, making it perfectly compatible with Dart Maps.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator <(
Pair< T1, T2> other) → bool -
Available on Pair<
Returns whether this pair is lexicographically less thanT1, T2> , provided by the ComparablePair extensionother. -
operator <=(
Pair< T1, T2> other) → bool -
Available on Pair<
Returns whether this pair is lexicographically less than or equal toT1, T2> , provided by the ComparablePair extensionother. -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Pair< T1, T2> other) → bool -
Available on Pair<
Returns whether this pair is lexicographically greater thanT1, T2> , provided by the ComparablePair extensionother. -
operator >=(
Pair< T1, T2> other) → bool -
Available on Pair<
Returns whether this pair is lexicographically greater than or equal toT1, T2> , provided by the ComparablePair extensionother.