def main(): users = ABB() parser = parserLastFM.parser('LastFM_small.dat', users, 100) #100 by 100 parser.next() #Load 100 #load 100 + 100 #parser.next() # users.inorder() users.swap() users.inorder() print users.depth()
def main(): users = ABB() parser = parserLastFM.parser('LastFM_small.dat', users, 100)#100 by 100 parser.next()#Load 100 #load 100 + 100 #parser.next() # users.inorder() users.swap() users.inorder() print users.depth()
def benchmarkModule(module): """returns a tuple with the average cost of add and search in ms in given module :param module: """ costs = {"add": [], "search": []} parser = parserLastFM.parser("LastFM_big.dat") users = module.emptyType() for i in xrange(10): users, cost = benchmarkFunction(module.add, users, parser) costs["add"].append(cost) for i in xrange(10): minRandom = random.uniform(0.0, 1.0) maxRandom = random.uniform(minRandom, 1.0) tmp, cost = benchmarkFunction(module.search, users, minRandom, maxRandom) costs["search"].append(cost) del users, parser return costs
lowers, highers = copy.copy(source), copy.copy(source) lowers.deleteHigher(minimum) highers.deleteLower(maximum) root = highers.min # the lowest of highers, can be the root highers.delete(root, wholeNode=True) result = ABB().insert(root) result.root.left = lowers.root result.root.right = highers.root return result def useful_info(tree): """Returns a string with useful info about the given ABB :type tree: ABB """ return "Depth: " + str(tree.depth) def emptyType(): return ABB() if __name__ == "__main__": parser = parserLastFM.parser("LastFM_small.dat") app = view.MainApp(parser, add, search, remove, useful_info, emptyType()) app.mainloop()
tmp = src_copy.pop() while tmp >= minimum: result.append(tmp) tmp = src_copy.pop() return cycle(result) if result else None # None if no results def remove(source, minimum=0.0, maximum=1.0): source.pop() return source def useful_info(heap): """ :type heap: Heap """ return "Depth: " + str(heap.depth) def emptyType(): return Heap() if __name__ == "__main__": parser = parserLastFM.parser("LastFM_small.dat") app = view.MainApp(parser, add, search, remove, useful_info, emptyType()) app.mainloop()
def initParser(filename): return parserLastFM.parser(filename, PQueue())
def initParser(filename): """Returns a parser ready for retrieve users from given file""" return parserLastFM.parser(filename, ABB())
def initparser(filename): return parserLastFM.parser(filename, Queue)