class_docstr: A simple balanced binary order statistic tree to help compute the concordance.
  
  When computing the concordance, we know all the values the tree will ever contain. That
  condition simplifies this tree a lot. It means that instead of crazy AVL/red-black shenanigans
  we can simply do the following:
  
  - Store the final tree in flattened form in an array (so node i's children are 2i+1, 2i+2)
  - Additionally, store the current size of each subtree in another array with the same indices
  - To insert a value, just find its index, increment the size of the subtree at that index and
    propagate
  - To get the rank of an element, you add up a bunch of subtree counts
class_docstr_tok: ["A","simple","balanced","binary","order","statistic","tree","to","help","compute","the","concordance",".","When","computing","the","concordance",",","we","know","all","the","values","the","tree","will","ever","contain",".","That","condition","simplifies","this","tree","a","lot",".","It","means","that","instead","of","crazy","AVL\/red-black","shenanigans","we","can","simply","do","the","following",":","-","Store","the","final","tree","in","flattened","form","in","an","array","(","so","node","i","'s","children","are","2i+1",",","2i+2",")","-","Additionally",",","store","the","current","size","of","each","subtree","in","another","array","with","the","same","indices","-","To","insert","a","value",",","just","find","its","index",",","increment","the","size","of","the","subtree","at","that","index","and","propagate","-","To","get","the","rank","of","an","element",",","you","add","up","a","bunch","of","subtree","counts"]
docstr: Returns the rank and count of the value in the btree.
docstr_tok: ["Returns","the","rank","and","count","of","the","value","in","the","btree","."]
code: def rank(self, value):
      """Returns the rank and count of the value in the btree."""
      i = 0
      n = len(self._tree)
      rank = 0
      count = 0
      while i < n:
          cur = self._tree[i]
          if value < cur:
              i = 2 * i + 1
              continue
          elif value > cur:
              rank += self._counts[i]
              # subtract off the right tree if exists
              nexti = 2 * i + 2
              if nexti < n:
                  rank -= self._counts[nexti]
                  i = nexti
                  continue
              else:
                  return (rank, count)
          else:  # value == cur
              count = self._counts[i]
              lefti = 2 * i + 1
              if lefti < n:
                  nleft = self._counts[lefti]
                  count -= nleft
                  rank += nleft
                  righti = lefti + 1
                  if righti < n:
                      count -= self._counts[righti]
              return (rank, count)
      return (rank, count)
  
imports: import numpy
label_desc: Use image node_id 5 for calling the _BTree obj's underlying member method code with example usage: obj.rank(value) and returns: rank,  count, rank,  count, rank,  count