예제 #1
0
 int getRank(int d) {
   if (d == data) {
     return left_size;
   } else if (d < data) {
     if (left == NULL) return -1;
     else return left->getRank(d);
   } else {
     int right_rank = (right == NULL ? -1 : right->getRank(d));
     if (right_rank == -1) return -1;
     else return left_size + 1 + right_rank;
   }
 }
예제 #2
0
 int getRank(int d) {
     if (d == data) {
         return left_size;
     } else if (d < data) {
         if (left == nullptr) {
             return -1;
         } else {
             return left->getRank(d);
         }
     } else {
         int right_rank = right == nullptr ? -1 : right->getRank(d);
         if (right_rank == -1) return -1;
         else return left_size + 1 + right_rank;
     }
 }
예제 #3
0
 int getRankOfNumber(int number) {
   return root->getRank(number);
 }