Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
ImmutableMap<K, V>
cajeta.collection.ImmutableMap — immutable, hash-indexed map: a frozen
snapshot of (key, value) pairs indexed by a read-only SwissTable. Entries
are stored once in dense arrays (insertion order, cheap to index by
keyAt / valAt) with an O(1) get / containsKey index built once — no
put, remove, tombstones, or resize. Built from an ArrayList<Pair<K, V>>;
duplicate keys resolve last-wins. Hashing and equality follow the HashMap
contract: K.hash() indexes, == decides key equality.
ArrayList<Pair<int32, int32>> src = heap ArrayList<Pair<int32, int32>>();
src.add(heap Pair<int32, int32>(1, 100));
src.add(heap Pair<int32, int32>(2, 200));
// The `#` surrenders `src`, whose pairs move into the map.
ImmutableMap<int32, int32> m = heap ImmutableMap<int32, int32>(#src);
int32 v = m.get(2); // 200
boolean has = m.containsKey(3); // false
int32 k0 = m.keyAt(0); // 1 — dense, insertion order
Methods
| Signature | |
|---|---|
ImmutableMap(#ArrayList<Pair<K, V>> src) ⚑ | Build a frozen map from src (last-wins on duplicate keys), which is consumed, so the call must write #src |
V get(K key) | Value bound to key, or the type’s zero value if absent |
boolean containsKey(K key) | True iff key is present |
V operator[] (K key) | Subscript sugar over get |
int64 count() | Number of entries |
boolean isEmpty() | True iff the map holds no entries |
K keyAt(int32 i) | Key at dense index i (0-based, insertion order); zero value if out of range |
V valAt(int32 i) | Value at dense index i (0-based, insertion order); zero value if out of range |
⚑ = @EntryPoint
See also
- Tour: ImmutableMapDemo
- Source:
runtime/src/cajeta/collection/ImmutableMap.cajeta - HashMap — the mutable counterpart
- Pair — the construction element type
- ImmutableList, ImmutableSet — the other frozen collections