コード例 #1
0
 private ImTreeMap(int hash, TKey key, TValue value, KeyValue <TKey, TValue>[] conficts, ImTreeMap <TKey, TValue> left, ImTreeMap <TKey, TValue> right)
 {
     Hash      = hash;
     Key       = key;
     Value     = value;
     Conflicts = conficts;
     Left      = left;
     Right     = right;
     Height    = 1 + (left.Height > right.Height ? left.Height : right.Height);
 }
コード例 #2
0
        public ImMap <TKey, TValue> AddOrUpdate(TKey key, TValue value)
        {
            var hash = key.GetHashCode();

            var treeIndex = hash & HashBitsToTree;

            var trees = _trees;
            var tree  = trees[treeIndex] ?? ImTreeMap <TKey, TValue> .Empty;

            tree = tree.AddOrUpdate(hash, key, value);

            var newTrees = new ImTreeMap <TKey, TValue> [NumberOfTrees];

            Array.Copy(trees, 0, newTrees, 0, NumberOfTrees);
            newTrees[treeIndex] = tree;

            return(new ImMap <TKey, TValue>(newTrees, Count + 1));
        }
コード例 #3
0
 private ImTreeMap <TKey, TValue> With(ImTreeMap <TKey, TValue> left, ImTreeMap <TKey, TValue> right)
 {
     return(left == Left && right == Right ? this : new ImTreeMap <TKey, TValue>(Hash, Key, Value, Conflicts, left, right));
 }