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
| Nombre | Restricciones |
|---|---|
T | IComparable<T> |
Herencia
- Clases base
-
AnySortedSet<T>
Constructores
new()
#
Propiedades
T Min { get; }
#
The smallest and largest items (an InvalidOperationError when the set is empty).
T Max { get; }
#
Métodos
Miembros privados e internos (1)
SortedDictionary<T, bool> tree
#
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
SortedSet<T> en Antril, descompilado a partir de su Larva HIR.
// 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();
}
}
}