protocol
_ArrayType
Inheritance |
ArrayLiteralConvertible, CollectionType, ExtensibleCollectionType, MutableCollectionType, MutableSliceable, RangeReplaceableCollectionType, SequenceType, Sliceable, _CollectionType, _ExtensibleCollectionType, _SequenceType, _Sequence_Type, _Sliceable, __ArrayType
View Protocol Hierarchy →
|
---|---|
Associated Types |
The collection type that represents a sub-range of elements. Though it can't currently be enforced by the type system, the
A type that represents a valid position in the collection. Valid indices consist of the position of every element and a "past the end" position that's not valid for use as a subscript.
A type that represents a valid position in the collection. Valid indices consist of the position of every element and a "past the end" position that's not valid for use as a subscript. 5 inherited items hidden. (Show all) |
Import |
|
Initializers
Construct an array of count elements, each initialized to repeatedValue
Declaration
init
(
count
:
Int
,
repeatedValue
:
Self
.
Generator
.
Element
)
Create an instance initialized with elements
.
Declaration
init
(
arrayLiteral
elements
:
Element
...)
Declared In
ArrayLiteralConvertible
1 inherited item hidden. (Show all)
Instance Variables
If the elements are stored contiguously, a pointer to the first element. Otherwise, nil.
Declaration
var
_baseAddressIfContiguous
:
UnsafeMutablePointer
<
Self
.
Element
>
{
get
}
An object that guarantees the lifetime of this array's elements
Declaration
var
_owner
:
AnyObject
? {
get
}
How many elements the Array stores
Declaration
var
count
:
Int
{
get
}
Declared In
_ArrayType
, __ArrayType
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()
.
Declaration
var
endIndex
:
Index
{
get
}
Declared In
_CollectionType
The position of the first element in a non-empty collection.
Identical to endIndex
in an empty collection.
Declaration
var
startIndex
:
Index
{
get
}
Declared In
_CollectionType
3 inherited items hidden. (Show all)
Subscripts
Declaration
subscript
(
position
:
Self
.
Index
) -
>
Self
.
Generator
.
Element
{
get
}
Declared In
CollectionType
, MutableCollectionType
Declaration
subscript
(
_
:
Range
<
Self
.
Index
>
) -
>
Self
.
SubSlice
{
get
set
}
Declared In
MutableSliceable
, Sliceable
3 inherited items hidden. (Show all)
Instance Methods
Operator form of extend
Declaration
func
+=
<
S
:
SequenceType
where
Self
.
Generator
.
Element
==
Self
.
Generator
.
Element
>
(
inout
lhs
:
Self
,
rhs
:
S
)
Declaration
func
_doCopyToNativeArrayBuffer
() -
>
_ContiguousArrayBuffer
<
Self
.
_Element
>
Declared In
__ArrayType
Append newElement to the Array in O(1) (amortized)
Declaration
mutating
func
append
(
newElement
:
Self
.
Generator
.
Element
)
Declared In
_ArrayType
, _ExtensibleCollectionType
Append elements from sequence
to the Array
Declaration
mutating
func
extend
<
S
:
SequenceType
where
Self
.
Generator
.
Element
==
Self
.
Generator
.
Element
>
(
sequence
:
S
)
Declared In
_ArrayType
, _ExtensibleCollectionType
Return a generator over the elements of this sequence.
Complexity: O(1)
Declaration
func
generate
() -
>
Generator
Declared In
SequenceType
, _Sequence_Type
Insert newElement
at index i
.
Invalidates all indices with respect to self
.
Complexity: O(count(self)
).
Requires: atIndex
<= count
Declaration
mutating
func
insert
(
newElement
:
Self
.
Generator
.
Element
,
atIndex
i
:
Int
)
Declared In
_ArrayType
, RangeReplaceableCollectionType
Declaration
func
join
<
S
:
SequenceType
where
Self
==
Self
>
(
elements
:
S
) -
>
Self
Declaration
func
reduce
<
U
>
(
initial
:
U
,
combine
: @
noescape
(
U
,
Self
.
Generator
.
Element
) -
>
U
) -
>
U
Erase all the elements. If keepCapacity
is true
, capacity
will not change
Declaration
mutating
func
removeAll
(#
keepCapacity
:
Bool
)
Declared In
_ArrayType
, RangeReplaceableCollectionType
Remove and return the element at the given index. Returns: the removed element. Worst case complexity: O(N). Requires: count > index
Declaration
mutating
func
removeAtIndex
(
index
:
Int
) -
>
Self
.
Generator
.
Element
Declared In
_ArrayType
, RangeReplaceableCollectionType
Remove an element from the end of the Array in O(1). Returns: the removed element. Requires: count > 0
Declaration
mutating
func
removeLast
() -
>
Self
.
Generator
.
Element
Remove the indicated subRange
of elements
Invalidates all indices with respect to self
.
Complexity: O(count(self)
).
Can be implemented as:
Swift
.
removeRange
(
&
self
,
subRange
)
Declaration
mutating
func
removeRange
(
subRange
:
Range
<
Self
.
Index
>
)
Declared In
RangeReplaceableCollectionType
Replace the given subRange
of elements with newElements
.
Invalidates all indices with respect to self
.
Complexity: O(count(subRange)
) if
subRange.endIndex == self.endIndex
and isEmpty(newElements)
,
O(count(self)
+ count(newElements)
) otherwise.
Declaration
mutating
func
replaceRange
<
C
:
CollectionType
where
Self
.
Generator
.
Element
==
Self
.
Generator
.
Element
>
(
subRange
:
Range
<
Self
.
Index
>
,
with
newElements
:
C
)
Declared In
RangeReplaceableCollectionType
Reserve enough space to store minimumCapacity elements.
PostCondition: capacity >= minimumCapacity
and the array has
mutable contiguous storage.
Complexity: O(count
)
Declaration
mutating
func
reserveCapacity
(
minimumCapacity
:
Int
)
Declared In
_ArrayType
, _ExtensibleCollectionType
Sort self
in-place according to isOrderedBefore
. Requires:
isOrderedBefore
induces a strict weak ordering
over the elements.
Declaration
mutating
func
sort
(
isOrderedBefore
: (
Self
.
Generator
.
Element
,
Self
.
Generator
.
Element
) -
>
Bool
)
Insert newElements
at index i
Invalidates all indices with respect to self
.
Complexity: O(count(self) + count(newElements)
).
Can be implemented as:
Swift
.
splice
(
&
self
,
newElements
,
atIndex
:
i
)
Declaration
mutating
func
splice
<
S
:
CollectionType
where
Self
.
Generator
.
Element
==
Self
.
Generator
.
Element
>
(
newElements
:
S
,
atIndex
i
:
Self
.
Index
)
Declared In
RangeReplaceableCollectionType
5 inherited items hidden. (Show all)
A type that provides the sequence's iteration interface and encapsulates its iteration state.