protocol
OptionSetType
Inheritance |
ArrayLiteralConvertible, Equatable, RawRepresentable, SetAlgebraType
View Protocol Hierarchy →
|
---|---|
Associated Types |
An
The "raw" type that can be used to represent all values of Every distinct value of 1 inherited item hidden. (Show all) |
Import |
|
Initializers
Convert from a value of RawValue
, succeeding unconditionally.
Declaration
init
(
rawValue
:
Self
.
RawValue
)
Declared In
OptionSetType
, RawRepresentable
Create an instance initialized with elements
.
Declaration
init
(
arrayLiteral
elements
:
Self
.
Element
...)
Declared In
ArrayLiteralConvertible
Creates the set containing all elements of sequence
.
Declaration
init
<
S
:
SequenceType
where
S
.
Generator
.
Element
==
Element
>
(
_
sequence
:
S
)
Declared In
SetAlgebraType
3 inherited items hidden. (Show all)
Instance Variables
The corresponding value of the "raw" type.
Self(rawValue: self.rawValue)!
is equivalent to self
.
Declaration
var
rawValue
:
Self
.
RawValue
{
get
}
Declared In
RawRepresentable
Return true iff self.contains(e)
is false
for all e
.
Declaration
var
isEmpty
:
Bool
{
get
}
Declared In
SetAlgebraType
2 inherited items hidden. (Show all)
Static Methods
Returns true
iff a
is disjoint with b
.
Two elements are disjoint when neither one subsumes the other.
See Also: Self.element(, subsumes:_)
Declaration
static
func
element
(
a
:
Self
.
Element
,
isDisjointWith
b
:
Self
.
Element
) -
>
Bool
Declared In
SetAlgebraType
Returns true
iff a
subsumes b
.
- Equivalent to
([a] as Self).isSupersetOf([b])
Declaration
static
func
element
(
a
:
Self
.
Element
,
subsumes
b
:
Self
.
Element
) -
>
Bool
Declared In
SetAlgebraType
2 inherited items hidden. (Show all)
Instance Methods
Return true if lhs
is equal to rhs
.
Equality implies substitutability. When x == y
, x
and
y
are interchangeable in any code that only depends on their
values.
Class instance identity as distinguished by triple-equals ===
is notably not part of an instance's value. Exposing other
non-value aspects of Equatable
types is discouraged, and any
that are exposed should be explicitly pointed out in
documentation.
Equality is an equivalence relation
x == x
istrue
x == y
impliesy == x
x == y
andy == z
impliesx == z
Inequality is the inverse of equality, i.e. !(x == y)
iff
x != y
.
Declaration
func
==(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Equatable
Returns true
if self
contains member
.
- Equivalent to
self.intersect([member]) == [member]
Declaration
func
contains
(
member
:
Self
.
Element
) -
>
Bool
Declared In
SetAlgebraType
Returns the set of elements contained in self
or in other
,
but not in both self
and other
.
Declaration
func
exclusiveOr
(
other
:
Self
) -
>
Self
Declared In
SetAlgebraType
Replaces self
with a set containing all elements contained in
either self
or other
, but not both.
- Equivalent to replacing
self
withself.exclusiveOr(other)
Declaration
mutating
func
exclusiveOrInPlace
(
other
:
Self
)
Declared In
SetAlgebraType
If member
is not already contained in self
, inserts it.
- Equivalent to
self.unionInPlace([member])
Postcondition:self.contains(member)
Declaration
mutating
func
insert
(
member
:
Self
.
Element
)
Declared In
SetAlgebraType
Returns the set of elements contained in both self
and other
.
Declaration
func
intersect
(
other
:
Self
) -
>
Self
Declared In
SetAlgebraType
Removes all elements of self
that are not also present in
other
.
- Equivalent to replacing
self
withself.intersect(other)
Postcondition:self.isSubsetOf(other)
Declaration
mutating
func
intersectInPlace
(
other
:
Self
)
Declared In
SetAlgebraType
Return true iff self.intersect(other).isEmpty
.
Declaration
func
isDisjointWith
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
Return true iff every element of self
is contained in other
.
Declaration
func
isSubsetOf
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
Return true iff every element of other
is contained in self
.
Declaration
func
isSupersetOf
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
If member
is contained in self
, removes and returns it.
Otherwise, removes all elements subsumed by member
and returns
nil
.
Postcondition: self.intersect([member]).isEmpty
Declaration
mutating
func
remove
(
member
:
Self
.
Element
) -
>
Self
.
Element
?
Declared In
SetAlgebraType
Return true iff self.intersect(other).isEmpty
.
Declaration
func
subtract
(
other
:
Self
) -
>
Self
Declared In
SetAlgebraType
Removes all elements of other
from self
.
- Equivalent to replacing
self
withself.subtract(other)
.
Declaration
mutating
func
subtractInPlace
(
other
:
Self
)
Declared In
SetAlgebraType
Returns the set of elements contained in self
, in other
, or in
both self
and other
.
Declaration
func
union
(
other
:
Self
) -
>
Self
Declared In
SetAlgebraType
Insert all elements of other
into self
.
- Equivalent to replacing
self
withself.union(other)
. Postcondition:self.isSupersetOf(other)
Declaration
mutating
func
unionInPlace
(
other
:
Self
)
Declared In
SetAlgebraType
15 inherited items hidden. (Show all)
Default Implementations
Creates the set containing all elements of sequence
.
Declaration
init
<
S
:
SequenceType
where
S
.
Generator
.
Element
==
Element
>
(
_
sequence
:
S
)
Declared In
SetAlgebraType
Creates a set containing all elements of the given arrayLiteral
.
This initializer allows an array literal containing
Self.Element
to represent an instance of the set, wherever it
is implied by the type context.
Declaration
init
(
arrayLiteral
:
Self
.
Element
...)
Declared In
SetAlgebraType
Returns true iff self.contains(e)
is false
for all e
.
Declaration
var
isEmpty
:
Bool
{
get
}
Declared In
SetAlgebraType
Returns true
iff a
is disjoint with b
.
Two elements are disjoint when neither one subsumes the other.
See Also: Self.element(, subsumes:_)
Declaration
static
func
element
(
a
:
Self
.
Element
,
isDisjointWith
b
:
Self
.
Element
) -
>
Bool
Declared In
SetAlgebraType
Returns true
iff a
subsumes b
.
- Equivalent to
([a] as Self).isSupersetOf([b])
Declaration
static
func
element
(
a
:
Self
.
Element
,
subsumes
b
:
Self
.
Element
) -
>
Bool
Declared In
SetAlgebraType
Returns the set of elements contained in self
or in other
,
but not in both self
and other
.
Declaration
func
exclusiveOr
(
other
:
Self
) -
>
Self
Returns the set of elements contained in both self
and other
.
Declaration
func
intersect
(
other
:
Self
) -
>
Self
Returns true iff self.intersect(other).isEmpty
.
Declaration
func
isDisjointWith
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
Return true iff every element of self
is contained in other
and other
contains an element that is not contained in self
.
Declaration
func
isStrictSubsetOf
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
Returns true iff every element of other
is contained in self
and self
contains an element that is not contained in other
.
Declaration
func
isStrictSupersetOf
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
Returns true iff every element of self
is contained in other
.
Declaration
func
isSubsetOf
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
Returns true iff every element of other
is contained in self
.
Declaration
func
isSupersetOf
(
other
:
Self
) -
>
Bool
Declared In
SetAlgebraType
Returns true iff self.intersect(other).isEmpty
.
Declaration
func
subtract
(
other
:
Self
) -
>
Self
Declared In
SetAlgebraType
Removes all elements of other
from self
.
- Equivalent to replacing
self
withself.subtract(other)
.
Declaration
mutating
func
subtractInPlace
(
other
:
Self
)
Declared In
SetAlgebraType
Returns the set of elements contained in self
, in other
, or in
both self
and other
.
Declaration
func
union
(
other
:
Self
) -
>
Self
12 inherited items hidden. (Show all)
Where Element == Self
Returns true
if self
contains member
.
- Equivalent to
self.intersect([member]) == [member]
Declaration
func
contains
(
member
:
Self
) -
>
Bool
If member
is not already contained in self
, insert it.
- Equivalent to
self.unionInPlace([member])
Postcondition:self.contains(member)
Declaration
mutating
func
insert
(
member
:
Self
)
If member
is contained in self
, remove and return it.
Otherwise, return nil
.
Postcondition: self.intersect([member]).isEmpty
Declaration
mutating
func
remove
(
member
:
Self
) -
>
Self
?
Where RawValue : BitwiseOperationsType
Create an empty instance.
- Equivalent to
[] as Self
Declaration
init
()
Replace self
with a set containing all elements contained in
either self
or other
, but not both.
- Equivalent to replacing
self
withself.exclusiveOr(other)
Declaration
mutating
func
exclusiveOrInPlace
(
other
:
Self
)
Remove all elements of self
that are not also present in
other
.
- Equivalent to replacing
self
withself.intersect(other)
Postcondition:self.isSubsetOf(other)
Declaration
mutating
func
intersectInPlace
(
other
:
Self
)
Insert all elements of other
into self
.
- Equivalent to replacing
self
withself.union(other)
. Postcondition:self.isSupersetOf(other)
Declaration
mutating
func
unionInPlace
(
other
:
Self
)
Supplies convenient conformance to
SetAlgebraType
for any type whoseRawValue
is aBitwiseOperationsType
. For example:In the example above,
PackagingOptions.Element
is the same type asPackagingOptions
, and instancea
subsumes instanceb
if and only ifa.rawValue & b.rawValue == b.rawValue
.