public void WriteToFile(MyBinaryWriter writer, Action <MyBinaryWriter, T> writeData) { writer.Write7BitEncodedInt(m_Subtries.Count); foreach (KeyValuePair <char, Trie <T> > subtrie in m_Subtries) { writer.WriteUTF16(subtrie.Key); subtrie.Value.WriteToFile(writer, writeData); } writer.Write7BitEncodedInt(Items.Count); foreach (T item in Items) { writeData(writer, item); } }
private void WriteToMiniFile(string charIndex, MyBinaryWriter writer, Action <MyBinaryWriter, T> writeData) { Debug.Assert(charIndex.Length <= 8); byte subTries = 0; for (int i = 0; i < charIndex.Length; i++) { if (m_Subtries.ContainsKey(charIndex[i])) { subTries |= (byte)(1 << i); } } writer.Write(subTries); //writer.Write7BitEncodedInt(m_Subtries.Count); //foreach (KeyValuePair<char, Trie<T>> subtrie in m_Subtries) for (int i = 0; i < charIndex.Length; i++) { if ((subTries & (1 << i)) == 0) { continue; } var subtrie = m_Subtries[charIndex[i]]; //writer.WriteUTF16(subtrie.Key); subtrie.WriteToMiniFile(charIndex, writer, writeData); } writer.Write7BitEncodedInt(Items.Count); foreach (T item in Items) { writeData(writer, item); } }