コード例 #1
0
def generation_mode(file_in, num, seed, file_del=None):
    words = synthetic.words(file_in, num, seed)

    size = input("How many lists should be in the hashmap?: ")
    try:
        size = int(size)
    except ValueError as e:
        print("ERROR: Invalid value was passed to the program.\n", e)
        return -1

    hash_table = HashTable(size)
    begin = time.perf_counter()
    hash_table.add_all(words)
    end = time.perf_counter()
    print("Adding time [s]: {:.6f}".format(end - begin))

    begin = time.perf_counter()
    for word in words:
        hash_table.find(word)
    end = time.perf_counter()
    print("Enumerating time [s]: {:.6f}".format(end - begin))

    if file_del is not None:
        words = synthetic.read_file(file_del)
    begin = time.perf_counter()
    for word in words:
        hash_table.delete_all(word)
    end = time.perf_counter()
    print("Deleting time [s]: {:.6f}".format(end - begin))
コード例 #2
0
def words_ready_mode(file_in, file_del=None):
    words = synthetic.read_file(file_in)
    print(words)

    size = input("How many lists should be in the hashmap?: ")
    try:
        size = int(size)
    except ValueError as e:
        print("ERROR: Invalid value was passed to the program.\n", e)
        return -1

    hash_table = HashTable(size)
    hash_table.add_all(words)
    for arr in hash_table.array:
        print(arr)

    if file_del is not None:
        words = synthetic.read_file(file_del)
    for word in words:
        hash_table.delete_all(word)

    for arr in hash_table.array:
        print(arr)