Exemplo n.º 1
0
        /// <summary>
        /// Creates a new set entry with the given values.
        /// </summary>
        private static SetEntry <TKey> CreateEntry <TKey>(SimpleSet <TKey> Set, TKey key, int hash)
        {
            SetEntry <TKey> newEntry;

            if (Set.EntryPool.Count > 0)
            {
                newEntry = Set.EntryPool[Set.EntryPool.Count - 1];
                SList.RemoveLast(Set.EntryPool); // remove last for better perfomance
            }
            else
            {
                newEntry = new SetEntry <TKey>();
            }

            newEntry.Key      = key;
            newEntry.HashCode = hash;
            return(newEntry);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new table entry with the given values.
        /// </summary>
        private static TableEntry <TKey, TValue> CreateEntry <TKey, TValue>(SimpleTable <TKey, TValue> table, TKey key, TValue value, int hash)
        {
            TableEntry <TKey, TValue> newEntry;

            if (table.EntryPool.Count > 0)
            {
                newEntry = table.EntryPool[table.EntryPool.Count - 1];
                SList.RemoveLast(table.EntryPool); // remove last for better perfomance
            }
            else
            {
                newEntry = new TableEntry <TKey, TValue>();
            }

            newEntry.Key      = key;
            newEntry.Value    = value;
            newEntry.HashCode = hash;
            return(newEntry);
        }