Detailed Method Reference

Namespace: Canley.Utility.CSV.Standard
Class: CSVTable<T>

Definition

public T GetRecord(int id)
  • Description: Performs an O(1) lookup to locate and return a specific record instance matching the provided unique integer ID.

  • Workflow:

    1. Index Lookup: Queries the internal integer-to-record lookup dictionary for the specified identifier.
    2. Retrieval: Returns the matching strongly-typed record instance, or null if no matching record exists in the table.
  • Parameters:

    • id: The unique integer identifier of the record to locate.
  • Returns: T - The matching record instance, or null if not found.

  • Example:

public void FindItemById(CSVTable<ItemRecord> itemTable, int targetId)
{
    ItemRecord record = itemTable.GetRecord(targetId);
    if (record != null)
    {
        Debug.Log(message: $"Found item: {record.itemName}");
    }
}

TIP

This method leverages the internal dictionary index maintained during hydration, making it ideal for high-frequency runtime queries where performance matters.