// assumed to be comparer // i.e. comp(x,x)=0, and comp(x,y)>0 then comp(y,x)<0, and comp(x,y)>0 & comp(y,z)>0 then comp(x,z)>0 public AVLTree(Comparison <T> comp) { sentinel = new AVLNode(this); sentinel.ResetAsSentinel(); this.comp = comp ?? DefaultComparison <T>(); if (typeof(T).IsValueType) { equals = (x, y) => x.Equals(y); } else { equals = (x, y) => ReferenceEquals(x, y); } count = 0; }
public void Clear() { sentinel.Left = sentinel; count = 0; sentinel.ResetAsSentinel(); }