/// <summary> /// Computes the appropriate string hash value for the given input text. /// </summary> /// <param name="text">The text to be hashed.</param> /// <returns>The string hash value.</returns> /// <remarks>Strings beginning with "0x" will be converted to numeric values.</remarks> public ulong StringHash(string text) { if (text.StartsWith("0x") && ulong.TryParse(text.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out ulong l)) { return(l); } switch (Options.HashMode) { case VaultHashMode.Hash32: return(VLT32Hasher.Hash(text)); case VaultHashMode.Hash64: return(VLT64Hasher.Hash(text)); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Called after all vaults have been loaded in order to generate a proper hierarchy. /// </summary> public void CompleteLoad() { Stopwatch stopwatch = Stopwatch.StartNew(); Dictionary <VltClass, ulong> hashDictionary = Classes.ToDictionary(c => c, c => VLT64Hasher.Hash(c.Name)); Dictionary <ulong, Dictionary <string, VltCollection> > collectionDictionary = RowManager.Rows.GroupBy(r => hashDictionary[r.Class]) .ToDictionary(g => g.Key, g => g.ToDictionary(c => c.Name, c => c)); for (int i = RowManager.Rows.Count - 1; i >= 0; i--) { VltCollection row = RowManager.Rows[i]; if (_parentKeyDictionary.TryGetValue(row, out string parentKey)) { VltCollection parentCollection = collectionDictionary[hashDictionary[row.Class]][parentKey]; parentCollection.AddChild(row); RowManager.Rows.RemoveAt(i); } } stopwatch.Stop(); _parentKeyDictionary.Clear(); }
public static void AddVLT(string str) { VltHashDictionary[VLT32Hasher.Hash(str)] = str; Vlt64HashDictionary[VLT64Hasher.Hash(str)] = str; }