Exemplo n.º 1
0
from HashTable import HashTable
import collections
import logging

h = HashTable() 

def open_file(file):
    with open(file) as f:
        for w in f.read().split():
            h.add_to_table(w, 1)                   
    return h.hashtable

print open_file("random.txt")
print h.add_to_table("the", 10)
print h.get_value("the")


#Performance test functions -> Speed

def time(word):
    import time
    start = time.clock()
    h.get_value(word)
    return time.clock() - start
    
'''
#Non-collision lookup times ------> 

print time("the")
# --> 1.79999999972e-05 
print time("a")
Exemplo n.º 2
0
from HashTable import HashTable
import collections
import logging

h = HashTable()


def open_file(file):
    with open(file) as f:
        for w in f.read().split():
            h.add_to_table(w, 1)
    return h.hashtable


print open_file("random.txt")
print h.add_to_table("the", 10)
print h.get_value("the")

#Performance test functions -> Speed


def time(word):
    import time
    start = time.clock()
    h.get_value(word)
    return time.clock() - start


'''
#Non-collision lookup times ------>