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
ImmutableSet<T>
cajeta.collection.ImmutableSet — immutable, hash-indexed set: a frozen,
de-duplicated snapshot of an ArrayList<T>. Members are stored once in a
dense array (so the set is cheaply indexable and streamable in first-seen
order) with a separate open-addressing table for O(1) contains, built once
at construction — no removal, tombstones, or resize. Hashing and equality
follow the HashMap / HashSet contract: T.hash() selects the bucket, ==
decides membership.
ArrayList<int32> src = heap ArrayList<int32>();
src.add(1);
src.add(2);
src.add(2);
// The `#` surrenders `src`, whose members move into the set.
ImmutableSet<int32> set = heap ImmutableSet<int32>(#src);
int64 n = set.count(); // 2 — duplicate dropped
boolean has = set.contains(2); // true
int32 first = set.get(0); // 1 — first-seen order preserved
Methods
| Signature | |
|---|---|
ImmutableSet(#ArrayList<T> src) ⚑ | Build a frozen, de-duplicated set from src (first occurrence wins), which is consumed, so the call must write #src |
int64 count() | Number of unique members |
boolean isEmpty() | count() == 0 |
boolean contains(T v) | True iff v is a member; O(1) average |
T get(int32 i) | Member at dense index i (0-based, first-seen order), or the type’s zero value if out of range |
#ArrayStream<T> stream() | Heap-allocated ArrayStream over the unique members, first-seen order |
⚑ = @EntryPoint
See also
- Tour: ImmutableSetDemo
- Source:
runtime/src/cajeta/collection/ImmutableSet.cajeta - HashSet — the mutable counterpart
- ImmutableList — the frozen list
- ArrayList — the construction source