Construct from another code point set of any type.
Construct a set from a forward range of code point intervals.
Construct a set from plain values of code point intervals.
Add an interval [a, b) to this set.
Sets support natural syntax for set algebra, namely:
Operator | Math notation | Description |
---|---|---|
& | a ∩ b | intersection |
| | a ∪ b | union |
- | a ∖ b | subtraction |
~ | a ~ b | symmetric set difference i.e. (a ∪ b) \ (a ∩ b) |
Tests the presence of codepoint ch in this set, the same as opIndex.
Tests the presence of code point val in this set.
The 'op=' versions of the above overloaded operators.
Obtains a set that is the inversion of this set.
Generates string with D source code of unary function with name of funcName taking a single dchar argument. If funcName is empty the code is adjusted to be a lambda function.
Obtain a textual representation of this InversionList in form of open-right intervals.
A range that spans each $(CODEPOINT) in this set.
Get range that spans all of the $(CODEPOINT) intervals in this InversionList.
True if this set doesn't contain any $(CODEPOINTS).
Obtains a set that is the inversion of this set.
Number of $(CODEPOINTS) in this set
auto a = CodepointSet('a', 'z'+1); auto b = CodepointSet('A', 'Z'+1); auto c = a; a = a | b; assert(a == CodepointSet('A', 'Z'+1, 'a', 'z'+1)); assert(a != c);
See also unicode for simpler construction of sets from predefined ones.
Memory usage is 8 bytes per each contiguous interval in a set. The value semantics are achieved by using the COW technique and thus it's not safe to cast this type to $(D_KEYWORD shared).
Note:
It's not recommended to rely on the template parameters or the exact type of a current $(CODEPOINT) set in std.uni. The type and parameters may change when the standard allocators design is finalized. Use isCodepointSet with templates or just stick with the default alias CodepointSet throughout the whole code base.
InversionList is a set of $(CODEPOINTS) represented as an array of open-right [a, b) intervals (see CodepointInterval above). The name comes from the way the representation reads left to right. For instance a set of all values [10, 50), [80, 90), plus a singular value 60 looks like this:
The way to read this is: start with negative meaning that all numbers smaller then the next one are not present in this set (and positive - the contrary). Then switch positive/negative after each number passed from left to right.
This way negative spans until 10, then positive until 50, then negative until 60, then positive until 61, and so on. As seen this provides a space-efficient storage of highly redundant data that comes in long runs. A description which Unicode $(CHARACTER) properties fit nicely. The technique itself could be seen as a variation on RLE encoding.
Sets are value types (just like int is) thus they are never aliased.