Esempio n. 1
0
        /// <summary>
        ///     Releases the lookup and any key and/or value nodes it contains to their respective pools.
        /// </summary>
        public void Dispose()
        {
            var valuesAcc = new LinkedHeadTail <T>();
            var runner    = keys.head;

            while (runner != null)
            {
                valuesAcc.Append(RemoveValues(runner.value));
                runner = runner.next;
            }

            if (dictionary.Count > 0)
            {
                SmoothLogger.LogWarning("Lookup had dictionary keys that were not in the key list.");
                foreach (var values in dictionary.Values)
                {
                    valuesAcc.Append(values);
                }
                dictionary.Clear();
            }

            keys.Dispose();
            valuesAcc.Dispose();

            lock (pool)
            {
                pool.Push(this);
            }
        }