public seqFrom ( object key, bool ascending ) : ISeq | ||
key | object | The key at which to start the iteration. |
ascending | bool | A flag indicating if the iteration is ascending or descending. |
Результат | ISeq |
public ISeq seqFrom(object key, bool ascending)
{
if (_count > 0)
{
ISeq stack = null;
Node t = _tree;
while (t != null)
{
int c = DoCompare(key, t.Key);
if (c == 0)
{
stack = RT.cons(t, stack);
return new Seq(stack, ascending);
}
else if (ascending)
{
if (c < 0)
{
stack = RT.cons(t, stack);
t = t.Left;
}
else
t = t.Right;
}
else
{
if (c > 0)
{
stack = RT.cons(t, stack);
t = t.Right;
}
else
t = t.Left;
}
}
if (stack != null)
return new Seq(stack, ascending);
}
return null;
}
/// <summary> /// Returns an <see cref="ISeq">ISeq</see> to iterate through the collection in the designated direction starting from a particular key. /// </summary> /// <param name="key">The key at which to start the iteration.</param> /// <param name="ascending">A flag indicating if the iteration is ascending or descending.</param> /// <returns>A sequence for first/rest iteration.</returns> /// <remarks>The key need not be in the collection. If not present, the iteration will start with /// the first element with a key greater than (if asscending) or less than (if descending) the given key.</remarks> public ISeq seqFrom(object key, bool ascending) { PersistentTreeMap m = (PersistentTreeMap)_impl; return(RT.keys(m.seqFrom(key, ascending))); }