def double_hash(hash1, hash2, i, m):
    """
    Finds a possible next position using double hashing

    Double hashing is one of the most efficient choices since it uses
    two independent hash functions to find the hash value. This
    results in not many collisions and not primary or secondary
    clustering

    The second hash function has to be relatively prime to the # of
    buckets (for example, if m is even, return a hash value that is
    odd (return x if x is odd, x+1 if x is even))

    :param hash1: First hash value
    :param hash2: Second hash value
    :param i: Offset
    :param m: Size of the table
    :return: The next index to be checked if it is open
    """
    return (hash1 + i*hash2) % m