Class IDGenerator
Class designed as a helper for situations where you need to generate and assign a unique integer to each instance of a class, eg. for a class implementing IHasID.
Inheritance
Inherited Members
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
public class IDGenerator
Remarks
The class may be initialized with a starting unsigned integer -- if none is given, 0 is the default starting point. To assign an ID, call UseID(), and assign the value that it returns. This class is NOT thread-safe on its own -- if it needs to be, you can simply use a lock to wrap any calls to UseID.
Constructors
| Improve this Doc View SourceIDGenerator(UInt32)
Constructor.
Declaration
public IDGenerator(uint startingInt = 0U)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | startingInt | Unsigned integer to start at (one that will be returned first time UseID() is called). Defaults to 0. |
Methods
| Improve this Doc View SourceUseID()
Call every time you wish to "assign" an ID. The integer returned will never be returned again (each integer returned by this function will be unique).
Declaration
public uint UseID()
Returns
Type | Description |
---|---|
System.UInt32 | The ID that has been assigned. |