pub struct LabelSet(/* private fields */);Expand description
Shared, copy-on-write set of labels carried by one record.
Wraps an Arc<BTreeSet<LabelId>>. Cloning a record — and therefore the
overlay delta maps that hold records, which a fresh writer seeds by cloning
its parent’s — shares the same allocation instead of deep-copying the set.
The first Self::insert into a SHARED set copies it once
(Arc::make_mut); a uniquely owned set mutates in place. The serde
representation is the plain label set, unchanged from the owned form.
§Performance
clone is O(1) (an Arc increment). Self::insert is O(log labels)
plus a one-time O(labels) copy when the set is still shared
(copy-on-write). Self::contains is O(log labels); Self::len and
Self::is_empty are O(1).
Implementations§
Source§impl LabelSet
impl LabelSet
Sourcepub fn iter(&self) -> impl Iterator<Item = LabelId> + '_
pub fn iter(&self) -> impl Iterator<Item = LabelId> + '_
Iterates the labels in ascending order.
§Performance
Creating the iterator is O(1); a full walk is O(labels).
Sourcepub fn insert(&mut self, label: LabelId) -> bool
pub fn insert(&mut self, label: LabelId) -> bool
Inserts label, returning whether it was newly added.
A no-op insert (the label is already present) never copies, so
re-asserting a label on a record whose set is still shared with a
parent overlay stays O(log labels).
§Performance
This method is O(log labels), plus a one-time O(labels)
copy-on-write when the set is shared and the label is new.