public HashTable([JetBrains.Annotations.NotNull] byte[] data) { using var ms = new MemoryStream(data); using var br = new BinaryReader(ms); for (long i = 0; i < data.Length; i += HashTableEntry.GetSize()) { var entryBytes = br.ReadBytes((int)HashTableEntry.GetSize()); var newEntry = new HashTableEntry(entryBytes); _entries.Add(newEntry); } }
/// <summary> /// Initializes a new instance of the <see cref="HashTable"/> class from /// a block of data containing hash table entries. /// </summary> /// <param name="data">Data.</param> public HashTable(byte[] data) { using (MemoryStream ms = new MemoryStream(data)) { using (BinaryReader br = new BinaryReader(ms)) { for (long i = 0; i < data.Length; i += HashTableEntry.GetSize()) { byte[] entryBytes = br.ReadBytes((int)HashTableEntry.GetSize()); HashTableEntry newEntry = new HashTableEntry(entryBytes); this.Entries.Add(newEntry); } } } }
public ulong GetSize() { return((ulong)(_entries.Count * HashTableEntry.GetSize())); }