Flags [Src] [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 unlying 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 [Src]
new iso create()
: Flags[A, B] iso^
Returns
- Flags[A, B] iso^
Public Functions
value [Src]
Returns the bit encoding of the set flags.
fun box value()
: B
Returns
- B
apply [Src]
Returns true if the flag is set.
fun box apply(
flag: A)
: Bool val
Parameters
- flag: A
Returns
- Bool val
all [Src]
Sets all bits, including undefined flags.
fun ref all()
: None val
Returns
- None val
clear [Src]
Unsets all flags.
fun ref clear()
: None val
Returns
- None val
set [Src]
Sets the flag.
fun ref set(
flag: A)
: None val
Parameters
- flag: A
Returns
- None val
unset [Src]
Unsets the flag.
fun ref unset(
flag: A)
: None val
Parameters
- flag: A
Returns
- None val
flip [Src]
Sets the flag if it is unset, unsets the flag if it is set.
fun ref flip(
flag: A)
: None val
Parameters
- flag: A
Returns
- None val
union [Src]
The union of this and that.
fun ref union(
that: Flags[A, B] box)
: None val
Parameters
- that: Flags[A, B] box
Returns
- None val
intersect [Src]
The intersection of this and that.
fun ref intersect(
that: Flags[A, B] box)
: None val
Parameters
- that: Flags[A, B] box
Returns
- None val
difference [Src]
The symmetric difference of this and that.
fun ref difference(
that: Flags[A, B] box)
: None val
Parameters
- that: Flags[A, B] box
Returns
- None val
remove [Src]
Unset flags that are set in that.
fun ref remove(
that: Flags[A, B] box)
: None val
Parameters
- that: Flags[A, B] box
Returns
- None val
add [Src]
This with the flag set.
fun box add(
flag: A)
: Flags[A, B] iso^
Parameters
- flag: A
Returns
- Flags[A, B] iso^
sub [Src]
This with the flag unset.
fun box sub(
flag: A)
: Flags[A, B] iso^
Parameters
- flag: A
Returns
- Flags[A, B] iso^
op_or [Src]
The union of this and that.
fun box op_or(
that: Flags[A, B] box)
: Flags[A, B] iso^
Parameters
- that: Flags[A, B] box
Returns
- Flags[A, B] iso^
op_and [Src]
The intersection of this and that.
fun box op_and(
that: Flags[A, B] box)
: Flags[A, B] iso^
Parameters
- that: Flags[A, B] box
Returns
- Flags[A, B] iso^
op_xor [Src]
The symmetric difference of this and that.
fun box op_xor(
that: Flags[A, B] box)
: Flags[A, B] iso^
Parameters
- that: Flags[A, B] box
Returns
- Flags[A, B] iso^
without [Src]
The flags in this that are not in that.
fun box without(
that: Flags[A, B] box)
: Flags[A, B] iso^
Parameters
- that: Flags[A, B] box
Returns
- Flags[A, B] iso^
clone [Src]
Create a clone.
fun box clone()
: Flags[A, B] iso^
Returns
- Flags[A, B] iso^
eq [Src]
Returns true if this has the same flags set as that.
fun box eq(
that: Flags[A, B] box)
: Bool val
Parameters
- that: Flags[A, B] box
Returns
- Bool val
lt [Src]
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.
fun box lt(
that: Flags[A, B] box)
: Bool val
Parameters
- that: Flags[A, B] box
Returns
- Bool val
le [Src]
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.
fun box le(
that: Flags[A, B] box)
: Bool val
Parameters
- that: Flags[A, B] box
Returns
- Bool val
gt [Src]
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.
fun box gt(
that: Flags[A, B] box)
: Bool val
Parameters
- that: Flags[A, B] box
Returns
- Bool val
ge [Src]
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.
fun box ge(
that: Flags[A, B] box)
: Bool val
Parameters
- that: Flags[A, B] box
Returns
- Bool val
compare [Src]
fun box compare(
that: Flags[A, B] box)
: (Less val | Equal val | Greater val)
Parameters
- that: Flags[A, B] box
Returns
ne [Src]
fun box ne(
that: Flags[A, B] box)
: Bool val
Parameters
- that: Flags[A, B] box
Returns
- Bool val