public override bool Equals(object ak_Obj) { k_BucketIterator lk_Iter = ak_Obj as k_BucketIterator; if (lk_Iter == null) { return(false); } return(mi_Index == lk_Iter.mi_Index && object.ReferenceEquals(mk_Table, lk_Iter.mk_Table)); }
public override int Distance(k_Iterator ak_Iter) { k_BucketIterator lk_Iter = ak_Iter as k_BucketIterator; if (lk_Iter == null || !object.ReferenceEquals(lk_Iter.Collection, this.Collection)) { throw new ArgumentException("Cannot determine distance of iterators belonging to different collections."); } k_Iterator lk_End = mk_Table.End; int li_IndexDiff; if (this != lk_End && ak_Iter != lk_End) { li_IndexDiff = mi_Index - lk_Iter.mi_Index; } else { li_IndexDiff = (this == lk_End) ? 1 : -1; // 1 is also fine when both are End } if (li_IndexDiff < 0) { int li_Diff = 0; k_Iterator lk_Bck = this.Clone(); for (; lk_Bck != ak_Iter && lk_Bck != lk_End; lk_Bck.Next()) { --li_Diff; } if (lk_Bck == ak_Iter) { return(li_Diff); } } else { int li_Diff = 0; k_Iterator lk_Fwd = ak_Iter.Clone(); for (; lk_Fwd != this && lk_Fwd != lk_End; lk_Fwd.Next()) { ++li_Diff; } if (lk_Fwd == this) { return(li_Diff); } } throw new Exception("Inconsistent state. Concurrency?"); }