コード例 #1
0
ファイル: mini-yelp.py プロジェクト: kid1211/AlgoPrep
 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
コード例 #2
0
 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
コード例 #3
0
ファイル: mini-yelp.py プロジェクト: RideGreg/LintCode
    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
コード例 #4
0
    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
コード例 #5
0
    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
コード例 #6
0
    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
コード例 #7
0
ファイル: mini-yelp.py プロジェクト: RideGreg/LintCode
 def add_restaurant(self, name, location):
     r = Restaurant.create(name, location)
     self.restaurants[r.id] = r
     return r.id
コード例 #8
0
ファイル: mini_yelp.py プロジェクト: Yang-YZ/System-Design
 def add_restaurant(self, name, location):
     self.restaurants[self.count] = Restaurant.create(name, location)
     self.count += 1
     return self.count - 1