class · System

SortedSet<T>

public class SortedSet<T : IComparable<T>>

A set kept in order: Add, Contains, Remove, Min, Max, and loop (T item in set) from the smallest.

Kind
class
Namespace
System
Assembly
System.Core
Access
public
Source file
Sorted.ant

Type parameters

NameConstraints
TIComparable<T>

Inheritance

Base classes
Any SortedSet<T>

Constructors

new()
#

Properties

i32 Count { get; }
#

read-only

bool IsEmpty { get; }
#

read-only

T Min { get; }
#

read-only

The smallest and largest items (an InvalidOperationError when the set is empty).

T Max { get; }
#

read-only

Methods

Add(T item) : bool
#

Adds item; false when it was there already.

Contains(T item) : bool
#
Remove(T item) : bool
#
Clear()
#
Iterator() : SortedSetIterator<T>
#

Private and internal members (1)

private

Inherited members (5)

Source

SortedSet<T> as Antril, decompiled from its Larva HIR.

System.SortedSet.ant
// System.SortedSet — System.Core (decompiled from Larva HIR)

into namespace System
{
	/// A set kept in order: Add, Contains, Remove, Min, Max, and `loop (T item in set)` from the smallest.
	public class SortedSet<T : IComparable<T>>
	{
		SortedDictionary<T, bool> tree;

		public:
			new()
			{
				tree = new SortedDictionary<T, bool>();
			}

			/// Adds `item`; false when it was there already.
			Add(T item) : bool
			{
				i32 before = tree.Count;
				tree.Set(item, true);
				return tree.Count != before;
			}

			Contains(T item) : bool => tree.ContainsKey(item);

			Remove(T item) : bool => tree.Remove(item);

			Clear()
			{
				tree.Clear();
			}

			Iterator() : SortedSetIterator<T> => new SortedSetIterator<T>(tree.Iterator());

			i32 Count
			{
				get => tree.Count;
			}

			bool IsEmpty
			{
				get => tree.Count == 0;
			}

			/// The smallest and largest items (an InvalidOperationError when the set is empty).
			T Min
			{
				get => tree.MinKey();
			}

			T Max
			{
				get => tree.MaxKey();
			}
	}
}
Esc