> 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.kseventmap-2.md).

# Class ksEventMap\<K, E>

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

A dictionary of events. Example Usage:

// Add an event handl map\[key] += handler;

// Remove an event ha map\[key] -= handler;

```csharp
public class ksEventMap<K, E> where E : ksIEvent, new()
```

#### Type Parameters

`K`

Key type

`E`

[ksEvent%601](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksEvent_601) or a class that derives from it.

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksEventMap\<K, E>](/reactor/api-reference/ks.reactor/ks.reactor.kseventmap-2.md)

#### 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)

## Fields

### m\_map <a href="#ks_reactor_kseventmap_2_m_map" id="ks_reactor_kseventmap_2_m_map"></a>

```csharp
protected Dictionary<K, E> m_map
```

#### Field Value

[Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2)\<K, E>

## Properties

### this\[K] <a href="#ks_reactor_kseventmap_2_item__0" id="ks_reactor_kseventmap_2_item__0"></a>

Gets the event object for a key. Creates one if none exists.

```csharp
public E this[K key] { get; set; }
```

#### Property Value

E

## Methods

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

Unregisters all events.

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

### CreateEventGroup(K) <a href="#ks_reactor_kseventmap_2_createeventgroup__0" id="ks_reactor_kseventmap_2_createeventgroup__0"></a>

Creates an event group for a key.

```csharp
protected virtual E CreateEventGroup(K key)
```

#### Parameters

`key` K

Key to create event group for.

#### Returns

E

Event group

### HasHandlers(K) <a href="#ks_reactor_kseventmap_2_hashandlers__0" id="ks_reactor_kseventmap_2_hashandlers__0"></a>

Checks if there are any handlers registered for a key.

```csharp
public bool HasHandlers(K key)
```

#### Parameters

`key` K

Key to check for.

#### Returns

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

True if there are any handlers registered for the key.

### TryGet(K, out E) <a href="#ks_reactor_kseventmap_2_tryget__0__1" id="ks_reactor_kseventmap_2_tryget__0__1"></a>

Tries to get the events for a key.

```csharp
public bool TryGet(K key, out E ev)
```

#### Parameters

`key` K

Key to get the events for.

`ev` E

Events for the given key, or null if none were found.

#### Returns

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

True if there was an events object for the given key.
