> ## Documentation Index
> Fetch the complete documentation index at: https://udcore.unrealdirective.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Array Functions

### Array\_NextIndex

Returns the next index in the array.

If the next index is greater than the last valid array index and bLoop is enabled, the index will loop back to the start of the array.
Otherwise, the last index of the array will be returned.

<Tabs>
  <Tab title="Blueprint">
    <Frame type="glass">
      <img src="https://mintcdn.com/unrealdirective/rXPzDrZHlafDpvFa/images/blueprints/blueprint-array-nextindex.jpg?fit=max&auto=format&n=rXPzDrZHlafDpvFa&q=85&s=d3710a33d7599378a05371942aa21cf6" width="850" height="360" data-path="images/blueprints/blueprint-array-nextindex.jpg" />
    </Frame>
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    TArray<int32> TargetArray = {0, 1, 2, 3};
    int32 Index = 2;
    bool bLoop = true;
    int32 NextIndex = UUDCoreFunctionLibrary::Array_NextIndex(TargetArray, Index, bLoop);
    ```
  </Tab>
</Tabs>

**Inputs**

<ParamField path="TargetArray" type="TArray<int32>" required>
  The array to get the next index for.
</ParamField>

<ParamField path="Index" type="int32" required>
  The current index.
</ParamField>

<ParamField path="bLoop" type="bool">
  If true, the index will loop back to the beginning of the array when the next index is greater than the last array index.
  Otherwise, the last index will be returned.
</ParamField>

**Outputs**

<ParamField path="ReturnValue" type="int32">
  The next index in the array.
</ParamField>

### Array\_PreviousIndex

Returns the previous index in the array.

If the previous index is less than 0 and bLoop is enabled, the index will loop back to the end of the array.
Otherwise, 0 will be returned.

<Tabs>
  <Tab title="Blueprint">
    <Frame type="glass">
      <img src="https://mintcdn.com/unrealdirective/rXPzDrZHlafDpvFa/images/blueprints/blueprint-array-previndex.jpg?fit=max&auto=format&n=rXPzDrZHlafDpvFa&q=85&s=a682437dd97d7f4c17398115fc32aae4" width="850" height="360" data-path="images/blueprints/blueprint-array-previndex.jpg" />
    </Frame>
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    TArray<int32> TargetArray = {0, 1, 2, 3};
    int32 Index = 1;
    bool bLoop = true;
    int32 PreviousIndex = UUDCoreFunctionLibrary::Array_PreviousIndex(TargetArray, Index, bLoop);
    ```
  </Tab>
</Tabs>

**Inputs**

<ParamField path="TargetArray" type="TArray<int32>" required>
  The array to get the previous index for.
</ParamField>

<ParamField path="Index" type="int32" required>
  The current index.
</ParamField>

<ParamField path="bLoop" type="bool">
  If true, the index will loop back to the end of the array when the previous index is less than 0.
  Otherwise, 0 will be returned.
</ParamField>

**Outputs**

<ParamField path="ReturnValue" type="int32">
  The previous index in the array.
</ParamField>
