VRage.Utils
MyStringHash
Assembly: VRage.dll
public struct MyStringHash: IEquatable<MyStringHash>, IXmlSerializable
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.
Fields
| Member | Description |
|---|---|
| static Comparer | |
| static NullOrEmpty | |
| m_hash |
Properties
| Member | Description |
|---|---|
| String |
Methods
| Member | Description |
|---|---|
| static Get(string) | |
| static GetOrCompute(string) | |
| static IsKnown(MyStringHash) | |
| static TryGet(string, out MyStringHash) | |
| static TryGet(string) | |
| static TryGet(int) | Think HARD before using this. Usually you should be able to use MyStringHash as it is without conversion to int. |
| Equals(object) | |
| Equals(MyStringHash) | |
| GetHashCode() | |
| GetSchema() | |
| ReadXml(XmlReader) | |
| ToString() | |
| WriteXml(XmlWriter) |
Implements:
- IEquatable
- IXmlSerializable prohibited