public void Init() { var r = new Random(4); _keys = new List <T>(); _immDict = ImmutableDictionary <T, int> .Empty; _sasaTrie = Trie <T, int> .Empty; _sGuh = ImmutableTrieDictionary.Create <T, int>(); _tvl = ImmutableTreeDictionary <T, int> .Empty; _imToolsHashMap = ImHashMap <T, int> .Empty; _apexHashMap = HashMap <T, int> .Empty; for (int i = 0; i < Count; ++i) { var k = GenerateValue(r); _immDict = _immDict.SetItem(k, i); _sasaTrie = _sasaTrie.Add(k, i); _sGuh = _sGuh.Add(k, i); _tvl = _tvl.Add(k, i); _imToolsHashMap = _imToolsHashMap.AddOrUpdate(k, i); _apexHashMap = _apexHashMap.SetItem(k, i); _keys.Add(k); } int n = _keys.Count; while (n > 1) { n--; int k = r.Next(n + 1); var value = _keys[k]; _keys[k] = _keys[n]; _keys[n] = value; } }
public void ImmutableTrieDictAdd() { immutableTrieDictionary.Clear(); for (int i = 0; i < N; i++) { immutableTrieDictionary.Add($"{i},{i}", i); } }
public void Clear_HasComparer_ReturnsEmptyWithOriginalComparer() { ImmutableTrieDictionary <string, int> dictionary = new Dictionary <string, int> { { "a", 1 } }.ToImmutableTrieDictionary(StringComparer.OrdinalIgnoreCase); ImmutableTrieDictionary <string, int> clearedDictionary = dictionary.Clear(); Assert.NotSame(ImmutableTrieDictionary <string, int> .Empty, clearedDictionary.Clear()); Assert.NotEmpty(dictionary); clearedDictionary = clearedDictionary.Add("a", 1); Assert.True(clearedDictionary.ContainsKey("A")); }
// internal override IBinaryTree GetRootNode<TKey, TValue>(IImmutableDictionary<TKey, TValue> dictionary) // { // return ((ImmutableTrieDictionary<TKey, TValue>)dictionary).Root; // } protected void ContainsValueTestHelper <TKey, TValue>(ImmutableTrieDictionary <TKey, TValue> map, TKey key, TValue value) { Assert.False(map.ContainsValue(value)); Assert.True(map.Add(key, value).ContainsValue(value)); }