public int Rank(int symbol, int position)
{
if (position < 0) {
return 0;
}
var ministring = this.SymbolCoder.Encode(symbol, null);
var node = this.Root;
var mlen = ministring.Count;
for (int i = 0; i < mlen; ++i) {
var code = ministring[i];
position = node.SEQ.Rank (code.symbol, position) - 1;
if (i+1 < mlen) {
node = node.CHILDREN[code.symbol] as WTM_Inner;
}
if (node == null) {
return 0;
}
}
return position + 1;
}