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
| Name | Constraints |
|---|---|
T | IComparable<T> |
Inheritance
- Base classes
-
AnySortedSet<T>
Constructors
new()
#
Properties
T Min { get; }
#
The smallest and largest items (an InvalidOperationError when the set is empty).
T Max { get; }
#
Methods
Private and internal members (1)
SortedDictionary<T, bool> tree
#
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
SortedSet<T> as Antril, decompiled from its 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();
}
}
}