public long GetUpperBoundForFactor(double factor)
{
if (0.0d >= factor || factor >= 1.0d)
{
throw new ArgumentOutOfRangeException("factor must be >= 0.0 and <= 1.0");
}
long totalCount = Count;
long tailTotal = totalCount - (long) Math.Round(totalCount*factor);
long tailCount = 0L;
for (int i = _counts.Length - 1; i >= 0; i--)
{
if (0L != _counts[i])
{
tailCount += _counts[i];
if (tailCount >= tailTotal)
{
return _upperBounds[i];
}
}
}
return 0L;
}