struct
DictionaryIndex
<
Key
:
Hashable
,
Value
>
Inheritance |
Comparable, Equatable, ForwardIndexType, _Incrementable
View Protocol Hierarchy →
|
---|---|
Import |
|
Instance Methods
Return the result of advancing self
by n
positions.
Returns:
- If n > 0
, the result of applying successor
to self
n
times.
- If n < 0
, the result of applying predecessor
to self
-n
times.
- Otherwise, self
.
Requires: n >= 0
if only conforming to ForwardIndexType
Complexity:
- O(1) if conforming to RandomAccessIndexType
- O(abs(n)
) otherwise
Declaration
func
advancedBy
(
n
:
DictionaryIndex
<
Key
,
Value
>
.
Distance
) -
>
DictionaryIndex
<
Key
,
Value
>
Declared In
ForwardIndexType
Return the result of advancing self
by n
positions, or until it
equals limit
.
Returns:
- If n > 0
, the result of applying successor
to self
n
times
but not past limit
.
- If n < 0
, the result of applying predecessor
to self
-n
times
but not past limit
.
- Otherwise, self
.
Requires: n >= 0
if only conforming to ForwardIndexType
.
Complexity:
- O(1) if conforming to RandomAccessIndexType
- O(abs(n)
) otherwise
Declaration
func
advancedBy
(
n
:
DictionaryIndex
<
Key
,
Value
>
.
Distance
,
limit
:
DictionaryIndex
<
Key
,
Value
>
) -
>
DictionaryIndex
<
Key
,
Value
>
Declared In
ForwardIndexType
Measure the distance between self
and end
.
Requires:
- start
and end
are part of the same sequence when conforming to
RandomAccessSequenceType
.
- end
is reachable from self
by incrementation otherwise.
Complexity:
- O(1) if conforming to RandomAccessIndexType
- O(n
) otherwise, where n
is the function's result.
Declaration
func
distanceTo
(
end
:
DictionaryIndex
<
Key
,
Value
>
) -
>
DictionaryIndex
<
Key
,
Value
>
.
Distance
Declared In
ForwardIndexType
Returns the next consecutive value after self
.
Requires: The next value is representable.
Declaration
func
successor
() -
>
DictionaryIndex
<
Key
,
Value
>
3 inherited items hidden. (Show all)
Used to access the key-value pairs in an instance of
Dictionary<Key, Value>
.Dictionary has two subscripting interfaces:
Subscripting with a key, yielding an optional value:
v = d[k]!
Subscripting with an index, yielding a key-value pair:
(k,v) = d[i]