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

NombreRestricciones
TIHashable<T>

Herencia

Clases base
Any HashSet<T>

Constructores

new()
#

Propiedades

i32 Count { get; }
#

read-only

Métodos

Add(T item) : bool
#

Adds item; false when it was already there.

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

loop (T item in set).

Miembros privados e internos (1)

Dictionary<T, bool> items
#

private

Miembros heredados (5)

Código fuente

HashSet<T> en Antril, descompilado a partir de su Larva HIR.

System.HashSet.ant
// 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;
			}
	}
}
Esc