Inheritance |
ArrayLiteralConvertible, CollectionType, DebugPrintable, Equatable, Hashable, Printable, Reflectable, SequenceType, _CollectionType, _SequenceType, _Sequence_Type
View Protocol Hierarchy →
|
---|---|
Associated Types |
Type alias inferred.
Type alias inferred. |
Import |
|
Initializers
Create an empty Set
.
Declaration
init
()
Create a Set
from a finite sequence of items.
Declaration
init
<
S
:
SequenceType
where
T
==
T
>
(
_
sequence
:
S
)
Declaration
init
(
arrayLiteral
elements
:
T
...)
Create an empty set with at least the given number of
elements worth of storage. The actual capacity will be the
smallest power of 2 that's >= minimumCapacity
.
Declaration
init
(
minimumCapacity
:
Int
)
Instance Variables
A textual representation of self
, suitable for debugging.
Declaration
var
debugDescription
:
String
{
get
}
The collection's "past the end" position.
endIndex
is not a valid argument to subscript
, and is always
reachable from startIndex
by zero or more applications of
successor()
.
Complexity: amortized O(1) if self
does not wrap a bridged
NSSet
, O(N) otherwise.
Declaration
var
endIndex
:
SetIndex
<
T
>
{
get
}
The first element obtained when iterating, or nil
if self
is
empty. Equivalent to self.generate().next()
Declaration
var
first
:
T
? {
get
}
Declaration
var
hashValue
:
Int
{
get
}
The position of the first element in a non-empty set.
This is identical to endIndex
in an empty set.
Complexity: amortized O(1) if self
does not wrap a bridged
NSSet
, O(N) otherwise.
Declaration
var
startIndex
:
SetIndex
<
T
>
{
get
}
Subscripts
Declaration
subscript
(
position
:
SetIndex
<
T
>
) -
>
T
{
get
}
Instance Methods
Return a new set with elements that are either in the set or a finite sequence but do not occur in both.
Declaration
func
exclusiveOr
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Set
<
T
>
For each element of a finite sequence, remove it from the set if it is a common element, otherwise add it to the set. Repeated elements of the sequence will be ignored.
Declaration
mutating
func
exclusiveOrInPlace
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
)
Return a generator over the members.
Complexity: O(1)
Declaration
func
generate
() -
>
SetGenerator
<
T
>
Returns the Index
of a given member, or nil
if the member is not
present in the set.
Declaration
func
indexOf
(
member
:
T
) -
>
SetIndex
<
T
>
?
Insert a member into the set.
Declaration
mutating
func
insert
(
member
:
T
)
Return a new set with elements common to this set and a finite sequence.
Declaration
func
intersect
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Set
<
T
>
Remove any members of this set that aren't also in a finite sequence.
Declaration
mutating
func
intersectInPlace
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
)
Returns true if no members in the set are in a finite sequence as a Set
.
Declaration
func
isDisjointWith
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Bool
Returns true if the set is a subset of a finite sequence as a Set
but not equal.
Declaration
func
isStrictSubsetOf
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Bool
Returns true if the set is a superset of a finite sequence as a Set
but not equal.
Declaration
func
isStrictSupersetOf
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Bool
Returns true if the set is a subset of a finite sequence as a Set
.
Declaration
func
isSubsetOf
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Bool
Returns true if the set is a superset of a finite sequence as a Set
.
Declaration
func
isSupersetOf
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Bool
Remove the member from the set and return it if it was present.
Declaration
mutating
func
remove
(
member
:
T
) -
>
T
?
Erase all the elements. If keepCapacity
is true
, capacity
will not decrease.
Declaration
mutating
func
removeAll
(
keepCapacity
:
Bool
=
default
)
Remove the member referenced by the given index.
Declaration
mutating
func
removeAtIndex
(
index
:
SetIndex
<
T
>
)
Remove a member from the set and return it. Requires: count > 0
.
Declaration
mutating
func
removeFirst
() -
>
T
Return a new set with elements in this set that do not occur in a finite sequence.
Declaration
func
subtract
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Set
<
T
>
Remove all members in the set that occur in a finite sequence.
Declaration
mutating
func
subtractInPlace
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
)
Return a new Set
with items in both this set and a finite sequence.
Declaration
func
union
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
) -
>
Set
<
T
>
Insert elements of a finite sequence into this Set
.
Declaration
mutating
func
unionInPlace
<
S
:
SequenceType
where
T
==
T
>
(
sequence
:
S
)
A collection of unique
T
instances with no defined ordering.