Skip to content

Commit

Permalink
Still fixing minor things
Browse files Browse the repository at this point in the history
  • Loading branch information
nbro committed Feb 14, 2017
1 parent 1ffd205 commit 6b97fb0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ands/ds/LinearProbingHashTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
## What's a hash map (or hash table)?
It's basically a data structure which is used to implement the so-called _associative arrays_,
It's basically a data structure which is used to implement the so-called _associative array_,
which is an abstract data type composed of a collection of (key, value) pairs,
such that each possible key appears at most once in the collection.
Expand All @@ -24,7 +24,7 @@
A hash function is any function that can be used to map data of arbitrary size to data of fixed size.
A perfect hash function is a function that assigns each key a unique bucket in the the data structure,
but most hash table designs employ an imperfect hash function, which might cause hash **collisions**,
where the hash function generates the same index for more than one key.
where the hash function generates the same index (i.e. the same position or bucket) for more than one key.
Such collisions must be accommodated in some way!!!
## Resolving collisions
Expand Down Expand Up @@ -58,7 +58,7 @@

from ands.ds.HashTable import HashTable

__all__ = ["LinearProbingHashTable"]
__all__ = ["LinearProbingHashTable", "has_duplicates_ignore_nones"]


class LinearProbingHashTable(HashTable):
Expand Down Expand Up @@ -87,13 +87,13 @@ def __init__(self, capacity: int = 11):
self._values = [None] * self._n

@property
def size(self):
def size(self) -> int:
"""Returns the number of pairs key-value in this map."""
self.__invariants__()
return sum(k is not None for k in self._keys)

@property
def capacity(self):
def capacity(self) -> int:
"""Returns the size of the internal buffers that store the keys and the values."""
self.__invariants__()
return len(self._keys)
Expand Down

0 comments on commit 6b97fb0

Please sign in to comment.