A list of key-value pairs that stays in the UPLC BuiltinPair representation, avoiding costly per-element conversions between PairData and ConstrData that occur when using List[(A, B)] with generic map/filter.
On JVM, PairList behaves like a regular list of tuples. On-chain, the compiler lowers it to the same SumDataPairList representation as List[(A, B)], so conversions via toList / toPairList are zero-cost (no UPLC code generated).
Pair-specific operations like mapValues operate directly on fstPair/sndPair builtins, yielding ~3x fewer builtin operations per element compared to List.map on tuples.
Type parameters
- A
-
the type of the first element (key)
- B
-
the type of the second element (value)
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
Members list
Value members
Concrete methods
Returns the first element of this PairList.
Returns the first element of this PairList.
Attributes
- Returns
-
The first key-value pair.
- Throws
-
NoSuchElementException
If the
PairListis empty. - Example
-
PairList.single("a", 1).head === ("a", 1)
Maps values while keeping keys unchanged.
Maps values while keeping keys unchanged.
On-chain this is significantly cheaper than List.map on tuples because it uses fstPair/sndPair builtins directly (~4 ops/element vs ~12).
Attributes
Returns all elements except the first.
Returns all elements except the first.
Attributes
- Returns
-
The tail of the
PairList. - Throws
-
NoSuchElementException
If the
PairListis empty.
Converts this PairList to a List[(A, B)].
Converts this PairList to a List[(A, B)].
On-chain this is a zero-cost operation (noop in UPLC) because both types share the same SumDataPairList representation.
Attributes
Converts this PairList to an AssocMap without validation. On-chain this is just mapData — no per-element conversion.
Converts this PairList to an AssocMap without validation. On-chain this is just mapData — no per-element conversion.
Attributes
Converts this PairList to a SortedMap without validation. On-chain this is just mapData — no per-element conversion.
Converts this PairList to a SortedMap without validation. On-chain this is just mapData — no per-element conversion.