ValueSet¶
- class dsviper.ValueSet¶
Bases:
ValueA value of type set<element_type>. Seamless with a Python seq[object].
Iterates in sorted order, not insertion order: a set built from ‘z’, ‘a’, ‘m’ reads back as ‘a’, ‘m’, ‘z’. Or use Value.create(type_set [, initial_value]).
An element of a set is its own key, so a set COPIES each element it takes: neither Value.create nor this constructor shares elements with what you passed. Being its own key is also why its index in sorted order is how one is addressed: s[index] reads that one in sorted order, and a Path reaches the same element with element(index).
- add(value: _InputValues) None¶
Add value to the set, or do nothing if it is already there.
The set stores a copy of the ELEMENT: it keeps its elements sorted and unique, so mutating value afterwards must not reach them. A map key is copied for the same reason; Value states the whole rule.
- at(index: int, *, encoded: Literal[True] = True) _OutputValues¶
Return the element at index.
encoded=False returns a Value rather than a native object.
index runs from 0 to len - 1; anything else is out of range, a negative one included. value[-1] follows Python’s own indexing.
- static cast(value: Value | _OutputValues) ValueSet¶
Return value as a set, or raise if it is not one.
- clear() None¶
Remove all elements from this set.
- description(*, namespace: NameSpace | None = None) str¶
Return the value written out, then its type, as <value>:<type>.
namespace qualifies the type name; representation() gives the value alone.
- difference(value: Iterable[Any]) ValueSet¶
Return a new set holding the elements of this set that value does not hold.
- difference_update(value: Iterable[Any]) None¶
Remove every element of value from this set.
- discard(value: _InputValues) None¶
Remove value from the set, or do nothing if it is not there.
- empty() bool¶
Return True if the container is empty.
- extend(elements: Sequence[Any] | ValueSet | ValueVector) None¶
Add every element of elements.
- hash() int¶
Return the hash value.
- index(value: _InputValues) int | None¶
Return the index of value in the sorted order, or None if the set does not hold it.
- intersection(value: Iterable[Any]) ValueSet¶
Return a new set holding the elements this set and value share.
- intersection_update(value: Iterable[Any]) None¶
Keep only the elements this set and value share.
- isdisjoint(value: Iterable[Any]) bool¶
Return True if this set and value share no element.
- issubset(value: Iterable[Any]) bool¶
Return True if value holds every element of this set.
- issuperset(value: Iterable[Any]) bool¶
Return True if this set holds every element of value.
- max(*, encoded: Literal[True] = True) _OutputValues¶
Return the maximum element or raise.
encoded=False returns a Value rather than a native object.
- min(*, encoded: Literal[True] = True) _OutputValues¶
Return the minimum element or raise.
encoded=False returns a Value rather than a native object.
- pop(*, encoded: Literal[True] = True) _OutputValues¶
Remove and return the min element. Raises error if the set is empty.
encoded=False returns a Value rather than a native object.
- pop_max(*, encoded: Literal[True] = True) _OutputValues¶
Remove and return the max element. Raises error if the set is empty.
encoded=False returns a Value rather than a native object.
- remove(value: _InputValues) None¶
Remove value from the set, raising KeyError if it is not there.
- representation() str¶
Return the value written out: the elements between braces, comma separated.
- size() int¶
Return the number of elements.
- symmetric_difference(value: Iterable[Any]) ValueSet¶
Return a new set holding the elements held by this set or by value, but not by both.
- symmetric_difference_update(value: Iterable[Any]) None¶
Keep only the elements held by this set or by value, but not by both.
- type_code() str¶
Return the code naming this kind of value, such as “int32”, “struct” or “vector”.
- union(value: Iterable[Any]) ValueSet¶
Return a new set holding every element of this set and of value.
- update(value: Iterable[Any]) None¶
Add every element of value to this set.