Ejemplo n.º 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, height: 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)), height: 2)
                     : new ImHashMap <K, V>(_data,
                                            Left, Right.AddOrUpdate(hash, key, value)).KeepBalance()))));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Scan a single assembly
        /// </summary>
        /// <param name="assembly"></param>
        /// <returns></returns>
        public static Task <AssemblyTypes> ForAssembly(Assembly assembly)
        {
            if (_assemblies.TryFind(assembly, out var types))
            {
                return(types);
            }

            types       = Task.Factory.StartNew(() => new AssemblyTypes(assembly));
            _assemblies = _assemblies.AddOrUpdate(assembly, types);

            return(types);
        }