예제 #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
파일: NanCodeWriter.cs 프로젝트: i-e-b/MECS
 /// <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);
        }