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

NameConstraints
KIComparable<K>
Vany type

Constructors

new(SortedDictionary<K, V> map)
#

Properties

KeyValuePair<K, V> Current { get; }
#

read-only

K Key { get; }
#

read-only

Methods

Next() : bool
#

Private and internal members (5)

SortedDictionary<K, V> map
#

private

i32[] stack
#

private

i32 depth
#

private

i32 current
#

private

Descend(i32 n)
#

private

Source

SortedIterator<K, V> as Antril, decompiled from its Larva HIR.

System.SortedIterator.ant
// 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);
			}
	}
}
Esc