 # http://docs.python.org/library/stdtypes.html#dict
 class Dict extends Mapping
   constructor: (iterable) ->
-    @value = {}
+    @value = {} # map from integer hashes to collision list
     if iterable?
       for key, value of iterable # TODO: Coffeescript uses in when using array, of when using object
         @__setitem__(key, value)
 
   # Checks if the key exists in this
   __contains__: (key) ->
-    return new Bool(hash(key).value of @value)
+    keyHash = hash(key).value
+    if @value[keyHash]?
+      collisionList = @value[keyHash]
+      for entry in collisionList
+        if key.__eq__(entry.key).value
+          return new Bool(true)
+    return new Bool(false)
 
   # Removes the key,value pair from this
   __delitem__: (key) ->
-    delete @value[hash(key).value]
-    return
+    if @__contains__(key).value
+      keyHash = hash(key).value
+      collisionList = @value[keyHash]
+      for entry, index in collisionList
+        if key.__eq__(entry.key).value
+            collisionList.splice(index, 1)
+            return
+    raise new KeyError("#{str(key).value}")
 
   # http://docs.python.org/release/2.3.5/ref/comparisons.html
   __eq__: (otherDict) ->


  # http://docs.python.org/library/stdtypes.html#dict.keys
  keys: ->
    ###
      TODO: Perform lookup on global hash-to-object-mapping table
        to get actual key objects instead of just their hashes
    ###
    keys = new List(Object.keys(@value))
    return keys

  # http://docs.python.org/library/stdtypes.html#dict.pop

  # Gets the item from this: like `x[key]`
  __getitem__: (key) ->
    if @__contains__(key).value
      keyHash = hash(key).value
      collisionList = @value[keyHash]
      for entry in collisionList
        if key.__eq__(entry.key).value
          return entry.value
    else
      raise new KeyError("#{str(key).value}")

