2273 Dictionaries

From Coder Merlin
Jump to navigation Jump to search
Coming Soon


Arrays are a collection type and enable us to quickly and easily access an element of the collection at a specific index, identified by an integer offset from the beginning of the collection. While arrays are very fast, they don’t provide us with the ability to quickly access an element given a key of arbitrary type.

Dictionaries are a type of hash table. A hash table is a data structure which implements the abstract data type associative array. The hash table uses a hash function to compute an index into an array of slots at which the element can be found. In a well-implemented algorithm, access to the element can occur in O(1).

n some cases, a hash function may not produce unique values. This is termed a collision. Collisions need to be appropriately resolved in order to access the proper element.

var d = Dictionary<String, Int>()
d[“Jack”] = 100
d[“Jill”] = 200


CoderMerlin™ proudly recommends:

Your purchase via these links helps to keep  Coder Merlin™ 's orbuculum ablaze. Thank you for your support!

Designed with pride in Silicon Valley, CA, USA