class · System
HashSet<T>
public class HashSet<T : IHashable<T>>
A set of values by hash: Add, Contains, Remove, and loop (T item in set).
- Tipo
- class
- Espacio de nombres
- System
- Ensamblado
- System.Core
- Acceso
- public
- Archivo fuente
Dictionary.ant
Parámetros de tipo
| Nombre | Restricciones |
|---|---|
T | IHashable<T> |
Herencia
- Clases base
-
AnyHashSet<T>
Constructores
new()
#
Propiedades
Métodos
Adds item; false when it was already there.
Clear()
#
Iterator() : ListIterator<T>
#
loop (T item in set).
Miembros privados e internos (1)
Dictionary<T, bool> items
#
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
HashSet<T> en Antril, descompilado a partir de su Larva HIR.
// System.HashSet — System.Core (decompiled from Larva HIR)
into namespace System
{
/// A set of values by hash: Add, Contains, Remove, and `loop (T item in set)`.
public class HashSet<T : IHashable<T>>
{
Dictionary<T, bool> items;
public:
new()
{
items = new Dictionary<T, bool>();
}
/// Adds `item`; false when it was already there.
Add(T item) : bool
{
if (items.ContainsKey(item))
return false;
items.Set(item, true);
return true;
}
Contains(T item) : bool => items.ContainsKey(item);
Remove(T item) : bool => items.Remove(item);
Clear()
{
items.Clear();
}
/// `loop (T item in set)`.
Iterator() : ListIterator<T> => items.Keys().Iterator();
i32 Count
{
get => items.Count;
}
}
}