> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.kshashset-1.md).

# Class ksHashSet\<T>

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

A hash set with an event that fires when the hash set is modified.

```csharp
public class ksHashSet<T> : ICollection<T>, IEnumerable<T>, IEnumerable
```

#### Type Parameters

`T`

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksHashSet\<T>](/reactor/api-reference/ks.reactor/ks.reactor.kshashset-1.md)

#### Implements

[ICollection\<T>](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1), [IEnumerable\<T>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksHashSet() <a href="#ks_reactor_kshashset_1__ctor" id="ks_reactor_kshashset_1__ctor"></a>

Constructor.

```csharp
public ksHashSet()
```

### ksHashSet(IEnumerable\<T>) <a href="#ks_reactor_kshashset_1__ctor_system_collections_generic_ienumerable__0" id="ks_reactor_kshashset_1__ctor_system_collections_generic_ienumerable__0"></a>

Constructor.

```csharp
public ksHashSet(IEnumerable<T> elements)
```

#### Parameters

`elements` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)\<T>

Elements to initialize the set with.

## Fields

### OnModify <a href="#ks_reactor_kshashset_1_onmodify" id="ks_reactor_kshashset_1_onmodify"></a>

Invoked when the hash set is modified.

```csharp
public ksHashSet<T>.ModifyHandler OnModify
```

#### Field Value

[ksHashSet](/reactor/api-reference/ks.reactor/ks.reactor.kshashset-1.md)\<T>.[ModifyHandler](/reactor/api-reference/ks.reactor/ks.reactor.kshashset-1/ks.reactor.kshashset-1.modifyhandler.md)

## Properties

### Count <a href="#ks_reactor_kshashset_1_count" id="ks_reactor_kshashset_1_count"></a>

The number of elements in the set.

```csharp
public int Count { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### IsReadOnly <a href="#ks_reactor_kshashset_1_isreadonly" id="ks_reactor_kshashset_1_isreadonly"></a>

Is this collection read-only? Always false.

```csharp
public bool IsReadOnly { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

## Methods

### Add(T) <a href="#ks_reactor_kshashset_1_add__0" id="ks_reactor_kshashset_1_add__0"></a>

Adds an element to the set if it is not already in the set.

```csharp
public bool Add(T element)
```

#### Parameters

`element` T

Element to add.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the element was added. False if it was already in the set.

### Add(params T\[]) <a href="#ks_reactor_kshashset_1_add__0" id="ks_reactor_kshashset_1_add__0"></a>

Adds elements to the set.

```csharp
public void Add(params T[] elements)
```

#### Parameters

`elements` T\[]

Elements to add.

### Add(IEnumerable\<T>) <a href="#ks_reactor_kshashset_1_add_system_collections_generic_ienumerable__0" id="ks_reactor_kshashset_1_add_system_collections_generic_ienumerable__0"></a>

Adds elements to the set.

```csharp
public void Add(IEnumerable<T> elements)
```

#### Parameters

`elements` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)\<T>

Elements to add.

### Clear() <a href="#ks_reactor_kshashset_1_clear" id="ks_reactor_kshashset_1_clear"></a>

Clears the set.

```csharp
public void Clear()
```

### Contains(T) <a href="#ks_reactor_kshashset_1_contains__0" id="ks_reactor_kshashset_1_contains__0"></a>

Checks if the set contains an element?

```csharp
public bool Contains(T element)
```

#### Parameters

`element` T

Element to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the element is in the set.

### ContainsAll(params T\[]) <a href="#ks_reactor_kshashset_1_containsall__0" id="ks_reactor_kshashset_1_containsall__0"></a>

Checks if the set contains all of the given elements.

```csharp
public bool ContainsAll(params T[] elements)
```

#### Parameters

`elements` T\[]

Elements to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if all of the elements are in the set.

### ContainsAll(IEnumerable\<T>) <a href="#ks_reactor_kshashset_1_containsall_system_collections_generic_ienumerable__0" id="ks_reactor_kshashset_1_containsall_system_collections_generic_ienumerable__0"></a>

Checks if the set contains all of the given elements.

```csharp
public bool ContainsAll(IEnumerable<T> elements)
```

#### Parameters

`elements` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)\<T>

Elements to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if all of the elements are in the set.

### ContainsAny(params T\[]) <a href="#ks_reactor_kshashset_1_containsany__0" id="ks_reactor_kshashset_1_containsany__0"></a>

Checks if the set contains any of the given elements.

```csharp
public bool ContainsAny(params T[] elements)
```

#### Parameters

`elements` T\[]

Elements to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if any of the elements are in the set.

### ContainsAny(IEnumerable\<T>) <a href="#ks_reactor_kshashset_1_containsany_system_collections_generic_ienumerable__0" id="ks_reactor_kshashset_1_containsany_system_collections_generic_ienumerable__0"></a>

Checks if the set contains any of the given elements.

```csharp
public bool ContainsAny(IEnumerable<T> elements)
```

#### Parameters

`elements` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)\<T>

Elements to check for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if any of the elements are in the set.

### CopyTo(T\[], int) <a href="#ks_reactor_kshashset_1_copyto__0___system_int32" id="ks_reactor_kshashset_1_copyto__0___system_int32"></a>

Copies the set elements into an array.

```csharp
public void CopyTo(T[] array, int arrayIndex)
```

#### Parameters

`array` T\[]

Array to copy elements into.

`arrayIndex` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Array index to start copying to.

### GetEnumerator() <a href="#ks_reactor_kshashset_1_getenumerator" id="ks_reactor_kshashset_1_getenumerator"></a>

Gets the enumerator.

```csharp
public HashSet<T>.Enumerator GetEnumerator()
```

#### Returns

[HashSet](https://learn.microsoft.com/dotnet/api/system.collections.generic.hashset-1)\<T>.[Enumerator](https://learn.microsoft.com/dotnet/api/system.collections.generic.hashset-1.enumerator)

### Remove(T) <a href="#ks_reactor_kshashset_1_remove__0" id="ks_reactor_kshashset_1_remove__0"></a>

Removes an element from the set.

```csharp
public bool Remove(T element)
```

#### Parameters

`element` T

Element to remove.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the element was removed. False if the element was not in the set.

### Remove(params T\[]) <a href="#ks_reactor_kshashset_1_remove__0" id="ks_reactor_kshashset_1_remove__0"></a>

Removes elements from the set.

```csharp
public void Remove(params T[] elements)
```

#### Parameters

`elements` T\[]

Elements to remove.

### Remove(IEnumerable\<T>) <a href="#ks_reactor_kshashset_1_remove_system_collections_generic_ienumerable__0" id="ks_reactor_kshashset_1_remove_system_collections_generic_ienumerable__0"></a>

Removes elements from the set.

```csharp
public void Remove(IEnumerable<T> elements)
```

#### Parameters

`elements` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)\<T>

Elements to remove.

### Set(params T\[]) <a href="#ks_reactor_kshashset_1_set__0" id="ks_reactor_kshashset_1_set__0"></a>

Clears the set and adds the given elements.

```csharp
public void Set(params T[] elements)
```

#### Parameters

`elements` T\[]

### Set(IEnumerable\<T>) <a href="#ks_reactor_kshashset_1_set_system_collections_generic_ienumerable__0" id="ks_reactor_kshashset_1_set_system_collections_generic_ienumerable__0"></a>

Clears the set and adds the given elements.

```csharp
public void Set(IEnumerable<T> elements)
```

#### Parameters

`elements` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)\<T>
