# ChunkEntityEnumerator

> Helper utility to quickly identify the next available entity or component within a chunk (e.g. the index of the NativeArray<T> retrieved via ArchetypeChunk.GetComponentDataPtrRW or ArchetypeChunk.GetEntityDataPtrRO )

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

```csharp
public struct ChunkEntityEnumerator
```

## Constructors

| Constructor                                                                                                                                                    | Description               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| [ChunkEntityEnumerator(System.Boolean,Unity.Burst.Intrinsics.v128,System.Int32)](/engine/7000.0/script-reference/unity/entities/chunkentityenumerator/ctor.md) | Construct a new instance. |

## Methods

| Method                                                                                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [IsSparse](/engine/7000.0/script-reference/unity/entities/chunkentityenumerator/issparse.md)                         | Returns whether the available entities are not a single contiguous run starting at slot 0 (i.e. there are gaps between available entities). A fully-available chunk returns false. Does not consume any entities, so it may be called before iterating.                                                                                                                                                                                                                                                                                                              |
| [NextEntityIndex](/engine/7000.0/script-reference/unity/entities/chunkentityenumerator/nextentityindex.md)           | Iterates through the given [ArchetypeChunk](/engine/7000.0/script-reference/unity/entities/archetypechunk.md), retrieving the index of the next available entity as defined by the mask info provided to the constructor.                                                                                                                                                                                                                                                                                                                                            |
| [NextEntityIndexBatch](/engine/7000.0/script-reference/unity/entities/chunkentityenumerator/nextentityindexbatch.md) | Iterates through the given [ArchetypeChunk](/engine/7000.0/script-reference/unity/entities/archetypechunk.md) a whole contiguous run of available entities at a time, rather than one index at a time as [ChunkEntityEnumerator.NextEntityIndex](/engine/7000.0/script-reference/unity/entities/chunkentityenumerator/nextentityindex.md) does. A run is a set of adjacent slots that are all available; batching lets a caller process a dense span in one operation. When every entity is available (the common case) this yields a single run `[0, chunk.Count)`. |
