// Find the rank of the node specified by key
// Note that the rank is 1-based integer. Rank 1 means the first node
//
// If the node is not found, 0 is returned. Otherwise rank(> 0) is returned
//
// Time complexity of this method is : O(log(N))
Find the rank of the node specified by key
Note that the rank is 1-based integer. Rank 1 means the first node

If the node is not found, 0 is returned. Otherwise rank(> 0) is returned

Time complexity of this method is : O(log(N))
// Find the rank of the node specified by key // Note that the rank is 1 - based integer . Rank 1 means the first node // // If the node is not found 0 is returned . Otherwise rank ( > 0 ) is returned // // Time complexity of this method is : O ( log ( N ))
func (this *SortedSet) FindRank(key string) int {
	this.mutex.RLock()
	defer this.mutex.RUnlock()
	var rank int = 0
	node := this.dict[key]
	if node != nil {
		x := this.header
		for i := this.level - 1; i >= 0; i-- {
			for x.level[i].forward != nil &&
				(x.level[i].forward.score < node.score ||
					(x.level[i].forward.score == node.score &&
						x.level[i].forward.key <= node.key)) {
				rank += int(x.level[i].span)
				x = x.level[i].forward
			}
			if x.key == key {
				return rank
			}
		}
	}
	return 0
}
func ( this * SortedSet ) FindRank ( key string ) int { this . mutex . RLock ( ) defer this . mutex . RUnlock ( ) var rank int = 0 node := this . dict [ key ] if node != nil { x := this . header for i := this . level - 1 ; i >= 0 ; i -- { for x . level [ i ] . forward != nil && ( x . level [ i ] . forward . score < node . score || ( x . level [ i ] . forward . score == node . score && x . level [ i ] . forward . key <= node . key ) ) { rank += int ( x . level [ i ] . span ) x = x . level [ i ] . forward } if x . key == key { return rank } } } return 0 }
Find the rank of the node specified by key
Note that the rank is 1-based integer.
Find the rank of the node specified by key Note that the rank is 1 - based integer .