예제 #1
0
 internal ImHashMap <K, V> AddOrUpdate(int hash, K key, V value)
 {
     return(Height == 0 // add new node
         ? new ImHashMap <K, V>(new Data(hash, key, value))
         : hash == Hash // update found node
             ? ReferenceEquals(Key, key) || Key.Equals(key)
                 ? new ImHashMap <K, V>(new Data(hash, key, value, Conflicts), Left, Right)
                 : UpdateValueAndResolveConflicts(key, value, null, false)
             : hash < Hash // search for node
                 ? Height == 1
                     ? new ImHashMap <K, V>(_data,
                                            new ImHashMap <K, V>(new Data(hash, key, value)), Right, 2)
                     : new ImHashMap <K, V>(_data,
                                            Left.AddOrUpdate(hash, key, value), Right).KeepBalance()
                 : Height == 1
                     ? new ImHashMap <K, V>(_data,
                                            Left, new ImHashMap <K, V>(new Data(hash, key, value)), 2)
                     : new ImHashMap <K, V>(_data,
                                            Left, Right.AddOrUpdate(hash, key, value)).KeepBalance());
 }
예제 #2
0
        public static string ToMessageTypeName(this Type type)
        {
            if (_typeNames.TryFind(type, out var alias))
            {
                return(alias);
            }

            var name = toMessageTypeName(type);

            _typeNames = _typeNames.AddOrUpdate(type, name);

            return(name);
        }