Exemplo n.º 1
0
        /// <summary>
        /// Produce statistics on distribution of bucket sizes. Current implementation is incomplete.
        /// </summary>
        /// <returns>Histogram data.</returns>
        public ISortedDictionary <int, int> BucketCostDistribution()
        {
            TreeDictionary <int, int> res = new TreeDictionary <int, int>();

            for (int i = 0, s = table.Length; i < s; i++)
            {
                int    count = 0;
                Bucket b     = table[i];

                while (b != null)
                {
                    count++;
                    b = b.overflow;
                }
                if (res.Contains(count))
                {
                    res[count]++;
                }
                else
                {
                    res[count] = 1;
                }
            }

            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            TreeDictionary <K, V> clone = new TreeDictionary <K, V>(Comparer, EqualityComparer);

            clone.sortedpairs.AddSorted(sortedpairs);
            return(clone);
        }
Exemplo n.º 3
0
        public SCG.IEnumerable <KeyValuePair <K, V> > Snapshot()
        {
            TreeDictionary <K, V> res = (TreeDictionary <K, V>)MemberwiseClone();

            res.pairs = (TreeSet <KeyValuePair <K, V> >)((TreeSet <KeyValuePair <K, V> >)sortedpairs).Snapshot();
            return(res);
        }
Exemplo n.º 4
0
        private static ISorted <SCG.KeyValuePair <K, V> > ClonePairs(TreeDictionary <K, V> template, bool isSnapshot)
        {
            TreeSet <SCG.KeyValuePair <K, V> > originalPairs = (TreeSet <SCG.KeyValuePair <K, V> >)template.Pairs;

            return(isSnapshot
                ? originalPairs.Snapshot()
                : (ISorted <SCG.KeyValuePair <K, V> >)originalPairs.Clone());
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates shallow clone or snapshot of other <see cref="T:TreeDictionary"/> instance.
 /// </summary>
 /// <param name="template">Dictionary to be cloned.</param>
 /// <param name="isSnapshot">Indicates whether clone must be a read-only snapshot.</param>
 private TreeDictionary(TreeDictionary <K, V> template, bool isSnapshot)
     : base(ClonePairs(template, isSnapshot), template.Comparer, template.EqualityComparer)
 {
 }