Show / Hide Table of Contents

Interface IHasID

Interface for a class that has an ID value, typically used for items in a spatial map, or generally for purposes of hashing.

Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public interface IHasID
Remarks

The ID assigned should be unique or close to unique over all instances of the class (to avoid hash collisions). A typical implementation could be simply randomly generating the ID value. To assign completely unique IDs, an IDGenerator can be used:

class SomeClass : IHasID
{
    // Static instance used to assign IDs to ANY new SomeClass instance
    private static IDGenerator generator = new IDGenerator();
    public uint ID { get; }

    public SomeClass(...)
    {
        ID = generator.UseID();
    }
}

Properties

| Improve this Doc View Source

ID

ID assigned to this object.

Declaration
uint ID { get; }
Property Value
Type Description
System.UInt32

Extension Methods

Utility.Yield<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX