Пример #1
0
 public static void AddMissingHash(int hash)
 {
     if (!m_missing.ContainsKey(hash))
     {
         m_missing.Add(hash, null);
     }
 }
Пример #2
0
 public static void AddToLookup(int hash, string value)
 {
     if (!m_lookup.ContainsKey(hash))
     {
         m_lookup.Add(hash, value);
     }
 }
Пример #3
0
 public static void AddToLookup(ulong hash, string value)
 {
     if (!lookup.ContainsKey(hash))
     {
         lookup.Add(hash, value);
     }
 }
Пример #4
0
        /// <summary>
        /// Returns a <see cref="ILookup{TKey, TElement}"/> that maps a <typeparamref name="TKey"/> to zero or more <typeparamref name="TValue"/>
        /// </summary>
        public static HashLookup <TKey, TValue> ToLookup <TKey, TValue>(this DbDataReader reader, Func <DbDataReader, TKey> keySelector, Func <DbDataReader, TValue> valueSelector)
        {
            var lookup = new HashLookup <TKey, TValue>();

            while (reader.Read())
            {
                var key   = keySelector(reader);
                var value = valueSelector(reader);
                lookup.Add(key, value);
            }
            return(lookup);
        }
Пример #5
0
 /// <summary>
 /// Add a single symbol reference
 /// </summary>
 public void AddSymbol(uint crushed, string name)
 {
     try {
         _symbols.Add(crushed, name);
     } catch {
         if (name == _symbols[crushed])
         {
             return;                            // same symbol.
         }
         throw new Exception("Hash collision between symbols!" +
                             " This is a compiler limitation, sorry." +
                             " Try renaming '" + _symbols[crushed] + "' or '" + name + "'");
     }
 }
Пример #6
0
        /// <summary>Returns a <see cref="HashLookup{TKey, TElement}"/> containing all the items in the sequence grouped by key</summary>
        public async static Task <HashLookup <TKey, TValue> > ToLookupAsync <TKey, TValue>(this IAsyncEnumerator <TValue> source, Func <TValue, TKey> keyFunc, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            var result = new HashLookup <TKey, TValue>();

            while (await source.MoveNextAsync(cancellationToken))
            {
                var key = keyFunc(source.Current);
                result.Add(key, source.Current);
            }
            return(result);
        }