Show / Hide Table of Contents

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
System.Object
IDGenerator
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

IDGenerator(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 Source

UseID()

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.

Extension Methods

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