Class UniqueNameSet<T>
Generates a unique name for every value it is passed. Generated names are stored, but not associated with the object they originated from: generating a name for the same object twice will always result in two different unique names. The resulting name will never be null or empty.
Inheritance
Inherited Members
Namespace: Flame.Collections
Assembly: Flame.dll
Syntax
public sealed class UniqueNameSet<T>
Type Parameters
Name | Description |
---|---|
T | The type of value to name. |
Constructors
| Improve this Doc View SourceUniqueNameSet(Func<T, String>, Func<T, Int32, String>)
Creates a unique name set from the given name-providing function, and a name-generating function that is used to resolve collisions.
Declaration
public UniqueNameSet(Func<T, string> getName, Func<T, int, string> generateName)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.String> | getName | A function that maps values to their preferred names. |
System.Func<T, System.Int32, System.String> | generateName | A function that takes a value and an integer and combines them into a name. This function is called with increasingly large integers when a collision occurs, until a unique name is found. |
UniqueNameSet(Func<T, String>, Func<T, Int32, String>, UniqueNameSet<T>)
Creates a unique name set from the given name-providing function, and a name-generating function that is used to resolve collisions. This unique set's name pool is aliased with the given other unique name set.
Declaration
public UniqueNameSet(Func<T, string> getName, Func<T, int, string> generateName, UniqueNameSet<T> alias)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.String> | getName | A function that maps values to their preferred names. |
System.Func<T, System.Int32, System.String> | generateName | A function that takes a value and an integer and combines them into a name. This function is called with increasingly large integers when a collision occurs, until a unique name is found. |
UniqueNameSet<T> | alias | A unique name set with which this unique name set's generated names are aliased. |
UniqueNameSet(Func<T, String>, String)
Creates a unique name set from the given name-providing function, and a prefix that is used to resolve collisions.
Declaration
public UniqueNameSet(Func<T, string> getName, string prefix)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.String> | getName | A function that maps values to their preferred names. |
System.String | prefix | A string prefix that is used to generate a unique name when a collision occurs. |
UniqueNameSet(Func<T, String>, String, UniqueNameSet<T>)
Creates a unique name set from the given name-providing function, and a prefix that is used to resolve collisions. This unique set's name pool is aliased with another unique name set.
Declaration
public UniqueNameSet(Func<T, string> getName, string prefix, UniqueNameSet<T> alias)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.String> | getName | A function that maps values to their preferred names. |
System.String | prefix | A string prefix that is used to generate a unique name when a collision occurs. |
UniqueNameSet<T> | alias | A unique name set with which this unique name set's generated names are aliased. |
Methods
| Improve this Doc View SourceGenerateName(T)
Generates a unique name for the given value.
Declaration
public string GenerateName(T element)
Parameters
Type | Name | Description |
---|---|---|
T | element | The value to generate a name for. |
Returns
Type | Description |
---|---|
System.String | A unique name. |
ReserveName(String)
Reserves a name, making sure it is never generated for any element.
Declaration
public bool ReserveName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name to reserve. |
Returns
Type | Description |
---|---|
System.Boolean |
|