<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [IterationMap](./server.iterationmap.md)

## IterationMap class

A high-performance Map-like data structure optimized for frequent iteration.

**Signature:**

```typescript
export default class IterationMap<K, V> 
```

## Remarks

IterationMap maintains both a Map for O(1) lookups and an Array for fast iteration, eliminating the need for Array.from() calls and providing \~2x faster iteration than Map.values(). Optimized for "build up, iterate, clear" usage patterns common in game loops.

## Example


```typescript
const iterationMap = new IterationMap<number, string>();
iterationMap.set(1, 'hello');
iterationMap.set(2, 'world');

// Fast O(1) lookup
const value = iterationMap.get(1);

// Fast array iteration (no Map.values() overhead)
for (const item of iterationMap.valuesArray) {
  console.log(item);
}

// Efficient bulk clear
iterationMap.clear();
```

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[size](./server.iterationmap.size.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

Returns the number of key-value pairs in the IterationMap.


</td></tr>
<tr><td>

[valuesArray](./server.iterationmap.valuesarray.md)


</td><td>

`readonly`


</td><td>

readonly V\[\]


</td><td>

Returns a readonly array of all values for fast iteration. This is the key performance feature - use this instead of .values() for iteration.


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[\[Symbol.iterator\]()](./server.iterationmap._symbol.iterator_.md)


</td><td>


</td><td>

Returns an iterator for the key-value pairs in the IterationMap.


</td></tr>
<tr><td>

[clear()](./server.iterationmap.clear.md)


</td><td>


</td><td>

Removes all key-value pairs from the IterationMap. Highly optimized for the common "build up, iterate, clear" pattern.


</td></tr>
<tr><td>

[delete(key)](./server.iterationmap.delete.md)


</td><td>


</td><td>

Removes the key-value pair from the IterationMap.


</td></tr>
<tr><td>

[entries()](./server.iterationmap.entries.md)


</td><td>


</td><td>

Returns an iterator for the key-value pairs in the IterationMap.


</td></tr>
<tr><td>

[forEach(callbackfn, thisArg)](./server.iterationmap.foreach.md)


</td><td>


</td><td>

Executes a provided function once for each key-value pair.


</td></tr>
<tr><td>

[get(key)](./server.iterationmap.get.md)


</td><td>


</td><td>

Returns the value associated with the key, or undefined if the key doesn't exist.


</td></tr>
<tr><td>

[has(key)](./server.iterationmap.has.md)


</td><td>


</td><td>

Returns true if the key exists in the IterationMap.


</td></tr>
<tr><td>

[keys()](./server.iterationmap.keys.md)


</td><td>


</td><td>

Returns an iterator for the keys in the IterationMap.


</td></tr>
<tr><td>

[set(key, value)](./server.iterationmap.set.md)


</td><td>


</td><td>

Sets the value for the key in the IterationMap.


</td></tr>
<tr><td>

[values()](./server.iterationmap.values.md)


</td><td>


</td><td>

Returns an iterator for the values in the IterationMap. Note: For performance-critical iteration, use .valuesArray instead.


</td></tr>
</tbody></table>
