(self, values)
return res
Given a sorted value list, return the rank of each element in this list
Given a sorted value list, return the rank of each element in this list
Given a sorted value list return the rank of each element in this list
def query_value_list(self, values):
        """
        Given a sorted value list, return the rank of each element in this list
        """
        self.compress()
        res = []
        min_rank, max_rank = 0, 0
        idx = 0
        sample_idx = 0

        while sample_idx < len(self.sampled):
            v = values[idx]
            sample = self.sampled[sample_idx]
            if sample.value < v:
                min_rank += sample.g
                max_rank = min_rank + sample.delta
                sample_idx += 1
            else:
                res.append((min_rank + max_rank) // 2)
                idx += 1
                if idx >= len(values):
                    break

        while idx < len(values):
            res.append((min_rank + max_rank) // 2)
            idx += 1
        return res
def query_value_list ( self , values ) : self . compress ( ) res = [ ] min_rank , max_rank = 0 , 0 idx = 0 sample_idx = 0 while sample_idx < len ( self . sampled ) : v = values [ idx ] sample = self . sampled [ sample_idx ] if sample . value < v : min_rank += sample . g max_rank = min_rank + sample . delta sample_idx += 1 else : res . append ( ( min_rank + max_rank ) // 2 ) idx += 1 if idx >= len ( values ) : break while idx < len ( values ) : res . append ( ( min_rank + max_rank ) // 2 ) idx += 1 return res