Flags[A: Flag[B] val, optional B: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Integer[B] val)]¶
Flags is a set of flags. The flags that are recognised should be passed as a union type for type parameter A. For example:
primitive SSE fun value(): U64 => 1
primitive AVX fun value(): U64 => 2
primitive RDTSCP fun value(): U64 => 4
type Features is Flags[(SSE | AVX | RDTSCP)]
Type parameter B is the underlying field used to store the flags.
class ref Flags[A: Flag[B] val, optional B: ((U8 val | U16 val | U32 val |
U64 val | U128 val | ULong val |
USize val) & Integer[B] val)] is
Comparable[Flags[A, B] box] ref
Implements¶
- Comparable[Flags[A, B] box] ref
Constructors¶
create¶
Create a Flags instance with an optional initial value. Default is 0 (no flags set).
Parameters¶
- value': B = 0
Returns¶
- Flags[A, B] iso^
Public Functions¶
value¶
Returns the bit encoding of the set flags.
Returns¶
- B
apply¶
Returns true if the flag is set.
Parameters¶
- flag: A
Returns¶
- Bool val
all¶
Sets all bits, including undefined flags.
Returns¶
- None val
clear¶
Unsets all flags.
Returns¶
- None val
set¶
Sets the flag.
Parameters¶
- flag: A
Returns¶
- None val
unset¶
Unsets the flag.
Parameters¶
- flag: A
Returns¶
- None val
flip¶
Sets the flag if it is unset, unsets the flag if it is set.
Parameters¶
- flag: A
Returns¶
- None val
union¶
The union of this and that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- None val
intersect¶
The intersection of this and that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- None val
difference¶
The symmetric difference of this and that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- None val
remove¶
Unset flags that are set in that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- None val
add¶
This with the flag set.
Parameters¶
- flag: A
Returns¶
- Flags[A, B] iso^
sub¶
This with the flag unset.
Parameters¶
- flag: A
Returns¶
- Flags[A, B] iso^
op_or¶
The union of this and that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Flags[A, B] iso^
op_and¶
The intersection of this and that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Flags[A, B] iso^
op_xor¶
The symmetric difference of this and that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Flags[A, B] iso^
without¶
The flags in this that are not in that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Flags[A, B] iso^
clone¶
Create a clone.
Returns¶
- Flags[A, B] iso^
eq¶
Returns true if this has the same flags set as that.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Bool val
lt¶
Returns true if the flags set on this are a strict subset of the flags set on that. Flags is only partially ordered, so lt is not the opposite of ge.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Bool val
le¶
Returns true if the flags set on this are a subset of the flags set on that or they are the same. Flags is only partially ordered, so le is not the opposite of te.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Bool val
gt¶
Returns true if the flags set on this are a struct superset of the flags set on that. Flags is only partially ordered, so gt is not the opposite of le.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Bool val
ge¶
Returns true if the flags set on this are a superset of the flags set on that or they are the same. Flags is only partially ordered, so ge is not the opposite of lt.
Parameters¶
- that: Flags[A, B] box
Returns¶
- Bool val
compare¶
Parameters¶
- that: Flags[A, B] box
Returns¶
ne¶
Parameters¶
- that: Flags[A, B] box
Returns¶
- Bool val