value · System
SortedIterator<K, V>
public value SortedIterator<K : IComparable<K>, V>
The pairs of a sorted map, from the smallest key: an in-order walk with its own stack.
- Kind
- value
- Namespace
- System
- Assembly
- System.Core
- Access
- public
- Source file
Sorted.ant
Type parameters
| Name | Constraints |
|---|---|
K | IComparable<K> |
V | any type |
Constructors
new(SortedDictionary<K, V> map)
#
Properties
KeyValuePair<K, V> Current { get; }
#
K Key { get; }
#
Methods
Private and internal members (5)
Source
SortedIterator<K, V> as Antril, decompiled from its Larva HIR.
// System.SortedIterator — System.Core (decompiled from Larva HIR)
into namespace System
{
/// The pairs of a sorted map, from the smallest key: an in-order walk with its own stack.
public value SortedIterator<K : IComparable<K>, V>
{
SortedDictionary<K, V> map;
i32[] stack;
i32 depth;
i32 current;
Descend(i32 n)
{
loop (n != 0)
{
stack[depth] = n;
depth++;
n = map.LeftOf(n);
}
}
public:
new(SortedDictionary<K, V> map)
{
this.map = map;
stack = new i32[48];
Descend(map.Root);
}
Next() : bool
{
if (depth == 0)
return false;
depth--;
current = stack[depth];
Descend(map.RightOf(current));
return true;
}
KeyValuePair<K, V> Current
{
get => new KeyValuePair<K, V>(map.KeyAt(current), map.ValueAt(current));
}
K Key
{
get => map.KeyAt(current);
}
}
}