Space Engineers
Public Member Functions | Properties | List of all members
VRage.EnumComparer< TEnum > Class Template Reference

A fast and efficient implementation of IEqualityComparer{T} for Enum types. Useful for dictionaries that use Enums as their keys. More...

Inheritance diagram for VRage.EnumComparer< TEnum >:

Public Member Functions

bool Equals (TEnum x, TEnum y)
 Determines whether the specified objects are equal. More...
 
int GetHashCode (TEnum obj)
 Returns a hash code for the specified object. More...
 
int Compare (TEnum x, TEnum y)
 

Properties

static EnumComparer< TEnum > Instance [get]
 The singleton accessor. More...
 

Detailed Description

A fast and efficient implementation of IEqualityComparer{T} for Enum types. Useful for dictionaries that use Enums as their keys.

var dict = new Dictionary<DayOfWeek, string>(EnumComparer<DayOfWeek>.Instance);

Template Parameters
TEnumThe type of the Enum.
Type Constraints
TEnum :struct 
TEnum :IComparable 
TEnum :IConvertible 
TEnum :IFormattable 

Definition at line 17 of file EnumComparer.cs.

Member Function Documentation

int VRage.EnumComparer< TEnum >.Compare ( TEnum  x,
TEnum  y 
)
inline

Definition at line 199 of file EnumComparer.cs.

bool VRage.EnumComparer< TEnum >.Equals ( TEnum  x,
TEnum  y 
)
inline

Determines whether the specified objects are equal.

Parameters
xThe first object of type TEnum to compare.
yThe second object of type TEnum to compare.
Returns
true if the specified objects are equal; otherwise, false.

Definition at line 82 of file EnumComparer.cs.

int VRage.EnumComparer< TEnum >.GetHashCode ( TEnum  obj)
inline

Returns a hash code for the specified object.

Parameters
objThe T:System.Object for which a hash code is to be returned.
Returns
A hash code for the specified object.
Exceptions
T:System.ArgumentNullExceptionThe type of obj is a reference type and obj is null.

Definition at line 98 of file EnumComparer.cs.

Property Documentation

EnumComparer<TEnum> VRage.EnumComparer< TEnum >.Instance
staticget

The singleton accessor.

Definition at line 65 of file EnumComparer.cs.


The documentation for this class was generated from the following file: