pub struct PersistentHashSet { /* private fields */ }Expand description
An immutable hash set that preserves insertion order when iterated.
Uses the same index-plus-ordered-log technique as PersistentHashMap:
a rpds::HashTrieMap from value to insertion sequence number, and a
rpds::RedBlackTreeMap from sequence number to value that is iterated in
order. This keeps iteration deterministic and matching insertion order,
rather than depending on hash-bucket layout — rpds seeds its hasher
randomly per instance, so raw hash-order iteration would otherwise vary
from run to run.
A set derived by conj or disj from a GC-allocated set reports only its
path-copied nodes from gc_size_extra; see collections::share_charge
for the full rule.
Implementations§
Source§impl PersistentHashSet
impl PersistentHashSet
pub fn empty() -> Self
pub fn count(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn contains(&self, val: &Value) -> bool
Sourcepub fn conj(&self, val: Value) -> Self
pub fn conj(&self, val: Value) -> Self
Return a new set with val added.
If val is already present, its original insertion position is kept.