def rankBookTree(catalog, fecha): """ Retorna la cantidad de llaves menores (titulos) dentro del arbol """ fecha = fecha + ' 00:00:00' fecha = strToDate(fecha, '%Y-%m-%d %H:%M:%S') return tree.rank(catalog['yearsTree_rank'], fecha, greater)
def test_rank(self): tree = omap.newMap() tree = omap.put(tree, 'A', 'Title 50', self.comparekeys) tree = omap.put(tree, 'C', 'Title 70', self.comparekeys) tree = omap.put(tree, 'E', 'Title 30', self.comparekeys) tree = omap.put(tree, 'H', 'Title 80', self.comparekeys) tree = omap.put(tree, 'L', 'Title 90', self.comparekeys) tree = omap.put(tree, 'M', 'Title 20', self.comparekeys) tree = omap.put(tree, 'P', 'Title 50', self.comparekeys) tree = omap.put(tree, 'R', 'Title 60', self.comparekeys) tree = omap.put(tree, 'S', 'Title 10', self.comparekeys) tree = omap.put(tree, 'X', 'Title 40', self.comparekeys) self.assertEqual(omap.rank(tree, "L", self.greater), 4)
def test_BSTRank(self): """ """ print('Test rank') tree = bst.newMap('BST') self.assertTrue(bst.isEmpty(tree)) bst.put(tree, '50', 'Title 50', self.comparekeys) bst.put(tree, '70', 'Title 70', self.comparekeys) bst.put(tree, '30', 'Title 30', self.comparekeys) bst.put(tree, '80', 'Title 80', self.comparekeys) bst.put(tree, '60', 'Title 60', self.comparekeys) bst.put(tree, '40', 'Title 40', self.comparekeys) bst.put(tree, '20', 'Title 20', self.comparekeys) bst.put(tree, '10', 'Title 10', self.comparekeys) bst.put(tree, '25', 'Title 25', self.comparekeys) bst.put(tree, '6', 'Title 6', self.comparekeys) bst.put(tree, '12', 'Title 12', self.comparekeys) bst.put(tree, '7', 'Title 7', self.comparekeys) bst.put(tree, '28', 'Title 28', self.comparekeys) rank = bst.rank(tree, '30', self.comparekeys) print("rank 30: ", rank)
def rankBookTree (catalog, bookTitle): """ Retorna la cantidad de llaves menores (titulos) dentro del arbol """ return tree.rank(catalog['booksTitleTree'], bookTitle, greater)
def rankAccidentMap (catalog, DateAccident): dateAcc = datetime.strptime(DateAccident, '%Y-%m-%d %H:%M:%S') return map.rank(catalog['AccidentsTree'], dateAcc, greater)
def rankAccidentMap (catalog, fecha): """ Retorna la cantidad de accidentes que ocurrieron antes que la fecha obtenida por parĂ¡metro """ return map.rank(catalog['accidentsTree'], fecha, greater)