Space Engineers
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
VRage.Utils.MyStringHash Struct Reference

Generates string hashes deterministically and crashes on collisions. When used as key for hash tables (Dictionary or HashSet) always pass in MyStringHash.Comparer, otherwise lookups will allocate memory! Can be safely used in network but never serialize to disk! More...

Inheritance diagram for VRage.Utils.MyStringHash:

Classes

class  HashComparerType
 

Public Member Functions

override string ToString ()
 
override int GetHashCode ()
 
override bool Equals (object obj)
 
bool Equals (MyStringHash id)
 

Static Public Member Functions

static bool operator== (MyStringHash lhs, MyStringHash rhs)
 
static bool operator!= (MyStringHash lhs, MyStringHash rhs)
 
static operator int (MyStringHash id)
 
static MyStringHash ()
 
static MyStringHash GetOrCompute (string str)
 
static MyStringHash Get (string str)
 
static bool TryGet (string str, out MyStringHash id)
 
static MyStringHash TryGet (string str)
 
static MyStringHash TryGet (int id)
 Think HARD before using this. Usually you should be able to use MyStringHash as it is without conversion to int. More...
 
static bool IsKnown (MyStringHash id)
 

Static Public Attributes

static readonly MyStringHash NullOrEmpty
 
static readonly HashComparerType Comparer = new HashComparerType()
 

Properties

string String [get]
 

Detailed Description

Generates string hashes deterministically and crashes on collisions. When used as key for hash tables (Dictionary or HashSet) always pass in MyStringHash.Comparer, otherwise lookups will allocate memory! Can be safely used in network but never serialize to disk!

IDs are computed as hash from string so there is a risk of collisions. Use only when MyStringId is not sufficient (eg. sending over network). Because the odds of collision get higher the more hashes are in use, do not use this for generated strings and make sure hashes are computed deterministically (eg. at startup) and don't require lengthy gameplay. This way we know about any collision early and not from rare and random crash reports.

Definition at line 20 of file MyStringHash.cs.

Constructor & Destructor Documentation

static VRage.Utils.MyStringHash.MyStringHash ( )
inlinestatic

Definition at line 94 of file MyStringHash.cs.

Member Function Documentation

override bool VRage.Utils.MyStringHash.Equals ( object  obj)
inline

Definition at line 53 of file MyStringHash.cs.

bool VRage.Utils.MyStringHash.Equals ( MyStringHash  id)
inline

Definition at line 58 of file MyStringHash.cs.

static MyStringHash VRage.Utils.MyStringHash.Get ( string  str)
inlinestatic

Definition at line 127 of file MyStringHash.cs.

override int VRage.Utils.MyStringHash.GetHashCode ( )
inline

Definition at line 48 of file MyStringHash.cs.

static MyStringHash VRage.Utils.MyStringHash.GetOrCompute ( string  str)
inlinestatic

Definition at line 106 of file MyStringHash.cs.

static bool VRage.Utils.MyStringHash.IsKnown ( MyStringHash  id)
inlinestatic

Definition at line 168 of file MyStringHash.cs.

static VRage.Utils.MyStringHash.operator int ( MyStringHash  id)
inlineexplicitstatic

Definition at line 66 of file MyStringHash.cs.

static bool VRage.Utils.MyStringHash.operator!= ( MyStringHash  lhs,
MyStringHash  rhs 
)
inlinestatic

Definition at line 64 of file MyStringHash.cs.

static bool VRage.Utils.MyStringHash.operator== ( MyStringHash  lhs,
MyStringHash  rhs 
)
inlinestatic

Definition at line 63 of file MyStringHash.cs.

override string VRage.Utils.MyStringHash.ToString ( )
inline

Definition at line 43 of file MyStringHash.cs.

static bool VRage.Utils.MyStringHash.TryGet ( string  str,
out MyStringHash  id 
)
inlinestatic

Definition at line 135 of file MyStringHash.cs.

static MyStringHash VRage.Utils.MyStringHash.TryGet ( string  str)
inlinestatic

Definition at line 143 of file MyStringHash.cs.

static MyStringHash VRage.Utils.MyStringHash.TryGet ( int  id)
inlinestatic

Think HARD before using this. Usually you should be able to use MyStringHash as it is without conversion to int.

Definition at line 156 of file MyStringHash.cs.

Member Data Documentation

readonly HashComparerType VRage.Utils.MyStringHash.Comparer = new HashComparerType()
static

Definition at line 87 of file MyStringHash.cs.

readonly MyStringHash VRage.Utils.MyStringHash.NullOrEmpty
static

Definition at line 22 of file MyStringHash.cs.

Property Documentation

string VRage.Utils.MyStringHash.String
get

Definition at line 33 of file MyStringHash.cs.


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