IdGenerator

Description

sealed class Tinman.Core.Util.IdGenerator<T ref>

Helper class that creates a bijective mapping between objects and integer identifiers.

An integer identifier (greater than zero) is assigned to each distinct value that is added to the IdGenerator object. Identifier values of removed mappings are not reused, so identifier values are truly unique.

Public / Constructors

IdGenerator


public constructor IdGenerator → (2)

equals opt : EqualsDelegate<T> = null

The equality comparer.

hashCode opt : HashCodeDelegate<T> = null

The hash code delegate.

Creates a new instance of IdGenerator.

Public / Methods

Clear


public method Clear → ()

Clears all object/identifier mappings.

IdToValue


public method IdToValue → (2)

identifier in : int32

The identifier.

defaultValue opt : T = default(T)

Value to return if no mapping exists.

returns → T

The mapped value.

Returns the object for the given identifier.

RemoveId


public method RemoveId → (1)

identifier in : int32

The identifier.

Removes the given mapping, if it exists.

RemoveValue


public method RemoveValue → (1)

value in : T

The object.

Removes the given mapping, if it exists.

TryValueToId


public method TryValueToId → (1)

value in : T

The object.

returns → int32

The identifier or 0 if no mapping exists.

Returns the identifier for the given object if a mapping exists.

ValueToId


public method ValueToId → (1)

value in : T

The object.

returns → int32

The identifier.

Returns the identifier for the given object, creating a new mapping if necessary.