示例#1
0
    def test_contains(self):
        table = ht.newMap(capacity=17, maptype='PROBING')

        ht.put(table, '1', 'title1', self.comparekeys)
        ht.put(table, '2', 'title2', self.comparekeys)
        ht.put(table, '3', 'title3', self.comparekeys)
        ht.put(table, '4', 'title4', self.comparekeys)
        ht.put(table, '5', 'title5', self.comparekeys)
        ht.put(table, '6', 'title6', self.comparekeys)

        self.assertTrue(ht.contains(table, '1', self.comparekeys))
        self.assertFalse(ht.contains(table, '15', self.comparekeys))
        self.assertTrue(ht.contains(table, '6', self.comparekeys))
        self.assertEqual(ht.size(table), 6)
    def test_contains(self):

        capacity = 10
        table = ht.newMap(capacity,
                          maptype='PROBING',
                          comparefunction=self.comparekeys)

        ht.put(table, '1', 'title1')
        ht.put(table, '2', 'title2')
        ht.put(table, '11', 'title3')
        ht.put(table, '3', 'title4')
        ht.put(table, '12', 'title5')
        ht.put(table, '5', 'title6')

        self.assertTrue(ht.contains(table, '1'))
        self.assertFalse(ht.contains(table, '15'))
        self.assertTrue(ht.contains(table, '11'))
示例#3
0
def addToHash (catalog, row):
    capacity_station = (row['dock_count'],row['id']) 
    if map.contains(catalog['capacityMap'],row['city']):
        statcapList = map.get(catalog['capacityMap'],row['city'])['value']
        lt.addLast(statcapList,capacity_station)
    else:
        stationCapacityList = lt.newList('ARRAY_LIST')
        lt.addLast(stationCapacityList,capacity_station)
        map.put(catalog['capacityMap'],row['city'], stationCapacityList)
示例#4
0
def addTempHash (catalog, row):
    hashTemp = catalog['temperatureHash']
    date = strToDate(row['date'], '%Y-%m-%d') #Convertir fecha a str
    if map.contains(catalog['temperatureHash'], row['mean_temperature_f']):
        dateIList = map.get(catalog['temperatureHash'], row['mean_temperature_f'])['value']
        lt.addLast(dateIList, date) 
        map.put(hashTemp, row['mean_temperature_f'], dateIList)
    else:
        dateList = lt.newList('ARRAY')
        lt.addLast(dateList, date)
        map.put(hashTemp, row['mean_temperature_f'], dateList)
示例#5
0
def addToTree (catalog, row):
    tree=catalog['dateTree'] #Árbol RBT ordenado por fecha
    date_raw= row['start_date'].split(" ")[0]
    date=strToDate(date_raw, '%m/%d/%Y') #Convertir fecha a str
    StationInf = map.get(catalog['stationMap'], row['start_station_id'])['value'][1] #Ciudad de la estación 
    if oms.contains(tree, date, greater):
        dateValue = oms.get(tree, date, greater)
        if map.contains(dateValue, StationInf):
            value = map.get(dateValue, StationInf)['value']
            map.put(dateValue, StationInf, value+1)
        else:
            map.put(dateValue, StationInf, 1)
        totalValue = map.get(dateValue, 'total')['value']
        totalValue += 1
        map.put(dateValue, 'total', totalValue)
        tree = oms.put(tree, date, dateValue, greater)
    else:
        DateValueMap = map.newMap(maptype='PROBING', comparefunction= compareByKey)
        map.put(DateValueMap, StationInf, 1)
        map.put(DateValueMap, 'total', 1)
        tree = oms.put(tree, date, DateValueMap, greater)
示例#6
0
 def test_contains(self):
     self.assertTrue   (ht.contains(self.table, '1', self.comparekeys))
     self.assertFalse  (ht.contains(self.table, '15', self.comparekeys))
     self.assertTrue   (ht.contains(self.table, '11', self.comparekeys))
示例#7
0
def contains(map, key):
    """
    Retorna True si la llave key se encuentra en la tabla de hash o False en caso contrario.  
    Es necesario proveer la función de comparación entre llaves. 
    """
    return ht.contains(map, key)