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).
- Kind
- class
- Namespace
- System
- Assembly
- System.Core
- Access
- public
- Source file
Dictionary.ant
Type parameters
| Name | Constraints |
|---|---|
T | IHashable<T> |
Inheritance
- Base classes
-
AnyHashSet<T>
Constructors
new()
#
Properties
Methods
Adds item; false when it was already there.
Clear()
#
Iterator() : ListIterator<T>
#
loop (T item in set).
Private and internal members (1)
Dictionary<T, bool> items
#
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
HashSet<T> as Antril, decompiled from its 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;
}
}
}