Show / Hide Table of Contents

Interface IHasID

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

Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.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

ID

ID assigned to this object.

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

Extension Methods

PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>)
PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>, EventHandler<ValueChangedEventArgs<TProperty>>)
In This Article
Back to top Generated by DocFX