Limen Framework 0.1 Help

TGridArray

Overview

TGridArray is a generic template class designed to manage a 2D array of elements. It provides methods for reserving space, converting between coordinates and indices, and accessing elements based on their coordinates. This class is useful for scenarios where data needs to be stored in a grid-like structure, such as tile-based games or spatial partitioning.

Properties

Type

Name

Access

Description

T*

Elements

Private

Pointer to the array of elements.

FIntVector2

Size

Private

The dimensions (width and height) of the grid.

Functions

Return Type

Signature

Description

void

Reserve(FIntVector2 Size)

Reserves space for a 2D array with the specified size.

int32

CoordinateToIndex(const FIntVector2 Coordinate) const

Converts a coordinate to its corresponding index in the array.

FIntVector2

IndexToCoordinate(const int32 Index) const

Converts an index back to its corresponding coordinate in the array.

Usage & Implementation Notes

  • The class uses dynamic memory allocation to manage the 2D array, which should be handled carefully to avoid memory leaks.

  • The Reserve function checks if the current elements pointer is not null before allocating new memory, ensuring that existing data is not lost.

  • The CoordinateToIndex and IndexToCoordinate functions include assertions to ensure that the provided coordinates or indices are within valid ranges.

22 May 2026