ios - What is the purpose of a DictionaryIndex in Swift? -
per header documentation on dictionary
in swift:
a hash-based mapping
key
value
instances. collection of key-value pairs no defined ordering.
note in particular- no defined ordering
.
with in mind, i'm having trouble understanding these computed variables (and related methods take these types):
// position of first element in non-empty dictionary. var startindex: dictionaryindex<key, value> { } // collection's "past end" position. var endindex: dictionaryindex<key, value> { }
the "index" here dictionaryindex
.
however, documentation on dictionaryindex
kinda circular here:
used access key-value pairs in instance of
dictionary<key, value>
.
what purpose of dictionaryindex
?
we know dictionary
composed of keys , values. every key mapped value based on internal calculations. here mechanism used purpose hashing.
from wikipedia:
a hash table uses hash function compute index array of buckets or slots, correct value can found.
consider dictionary
hash table, uses hash function , returns object of type dictionaryindex
- using can access particular object directly in dictionary.
correct me if wrong!
Comments
Post a Comment