/// <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); }
/// <summary> /// /// </summary> /// <returns></returns> public override object Clone() { TreeDictionary <K, V> clone = new TreeDictionary <K, V>(Comparer, EqualityComparer); clone.sortedpairs.AddSorted(sortedpairs); return(clone); }
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); }
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()); }
/// <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) { }