def add_restaurant(self, name, location): restaurant = Restaurant.create(name, location) hashcode = "%s.%s" % (GeoHash.encode(location), restaurant.id) bisect.insort(self.geo_value, hashcode) self.restaurants[hashcode] = restaurant self.ids[restaurant.id] = hashcode return restaurant.id
def add_restaurant(self, name, location): # Write your code here restaurant = Restaurant.creat(name, location) hashcode = "%s.%s" % (GeoHash.encode(location), restaurant.id) bisect.insort(self.geo_value, hashcode) self.restaurants[hashcode] = restaurant self.ids[restaurant.id] = hashcode return restaurant.id
def add_restaurant(self, name, location): # Write your code here rest = Restaurant.create(name, location) code = "%s.%s" % (GeoHash.encode(location), rest.id) self.codes[rest.id] = code self.rests[code] = rest bisect.insort(self.geos, code) return rest.id
def add_restaurant(self, name, location): r = Restaurant.create(name, location) # add r.id incase two locations has the same geohash hashcode = "{}.{}".format(GeoHash.encode(location), r.id) self.restaurants[hashcode] = r self.id2hashcode[r.id] = hashcode bisect.insort(self.geo_value, hashcode) return r.id
def add_restaurant(self, name, location): restaurant = Restaurant.create(name, location) hashcode = self.get_restr_hashcode(restaurant) self.restaurants[hashcode] = restaurant self.restr_to_geohash[restaurant.id] = hashcode bisect.insort(self.geohashs, hashcode) return restaurant.id
def add_restaurant(self, name, location): restaurant = Restaurant.create(name, location) hashcode = self.get_restr_hashcode(restaurant) self.restaurants[hashcode] = restaurant self.restr_to_geohash[restaurant.id] = hashcode self.trie.put(hashcode) return restaurant.id
def add_restaurant(self, name, location): restaurant = Restaurant.create(name, location) r_id = restaurant.id self.id2restaurant[r_id] = restaurant geocode = GeoHash.encode(location) for i in range(9): self.loc_table[i][geocode[:i]].add(r_id) return r_id
def add_restaurant(self, name, location): restaurant = Restaurant(name, location) self.restaurant_serial_id += 1 restaurant_id = self.restaurant_serial_id self.id2restaurant[restaurant_id] = restaurant geohash = GeoHash.encode(location) for i in range(0, 6): key = geohash[:i] if key not in self.geohash_table: self.geohash_table[key] = set() self.geohash_table[key].add(restaurant_id) return restaurant_id
def add_restaurant(self, name, location): r = Restaurant.create(name, location) self.restaurants[r.id] = r return r.id
def add_restaurant(self, name, location): self.restaurants[self.count] = Restaurant.create(name, location) self.count += 1 return self.count - 1