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.

Tipo
class
Espacio de nombres
System
Ensamblado
System.Core
Acceso
public
Archivo fuente
Sorted.ant

Parámetros de tipo

NombreRestricciones
TIComparable<T>

Herencia

Clases base
Any SortedSet<T>

Constructores

new()
#

Propiedades

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

Métodos

Add(T item) : bool
#

Adds item; false when it was there already.

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

Miembros privados e internos (1)

private

Miembros heredados (5)

Código fuente

SortedSet<T> en Antril, descompilado a partir de su 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