public static void Fill(k_Iterator ak_DstFirst, k_Iterator ak_BehindDstLast, object ak_Value) { for (k_Iterator lk_Iter = ak_DstFirst.Clone(); lk_Iter != ak_BehindDstLast; lk_Iter.Next()) { lk_Iter.Current = ak_Value; } }
public void Insert(k_Iterator ak_SrcBegin, k_Iterator ak_SrcEnd) { for (k_Iterator lk_Iter = ak_SrcBegin.Clone(); lk_Iter != ak_SrcEnd; lk_Iter.Next()) { Add((DictionaryEntry)lk_Iter.Current); } }
public static k_Iterator Copy(k_Iterator ak_SrcFirst, k_Iterator ak_BehindSrcLast, k_Iterator ak_DstFirst) { k_Iterator lk_Src = ak_SrcFirst.Clone(), lk_Dst = ak_DstFirst.Clone(); while (lk_Src != ak_BehindSrcLast) { lk_Dst.Current = lk_Src.Current; lk_Src.Next(); lk_Dst.Next(); } return(lk_Dst); }
public static k_Iterator CopyBackward(k_Iterator ak_SrcFirst, k_Iterator ak_BehindSrcLast, k_Iterator ak_BehindDstLast) { k_Iterator lk_Src = ak_BehindSrcLast.Clone(), lk_Dst = ak_BehindDstLast.Clone(); while (lk_Src != ak_SrcFirst) { lk_Src.Prev(); lk_Dst.Prev(); lk_Dst.Current = lk_Src.Current; } return(lk_Dst); }
public override int Distance(k_Iterator ak_Iter) { k_NodeIterator lk_Iter = ak_Iter as k_NodeIterator; 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_Tree.End; int li_KeyDiff; if (this == lk_End || ak_Iter == lk_End) { li_KeyDiff = (this == lk_End && this != ak_Iter) ? 1 : 0; } else { li_KeyDiff = mk_Tree.mk_Comparer.Compare(mk_Current.Key, lk_Iter.mk_Current.Key); } if (li_KeyDiff <= 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); } } if (li_KeyDiff >= 0) { 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?"); }
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?"); }
public static k_Iterator Find(k_Iterator ak_First, k_Iterator ak_Last, object ak_Value) { k_Iterator lk_Iter = ak_First.Clone(); for (; lk_Iter != ak_Last; lk_Iter.Next()) { if (object.Equals(lk_Iter.Current, ak_Value)) { break; } } return(lk_Iter); }
public k_Iterator Erase(k_Iterator ak_First, k_Iterator ak_Last) { if (ak_First == this.Begin && ak_Last == this.End) { Clear(); return(ak_Last.Clone()); } k_Iterator lk_Current = ak_First; while (lk_Current != ak_Last) { lk_Current = Erase(lk_Current); } return(lk_Current); }
public void Insert(k_Iterator ak_Where, k_Iterator ak_SrcBegin, k_Iterator ak_SrcEnd) { //System.Diagnostics.Debug.Assert(object.ReferenceEquals(this, ak_Where.Collection), "Iterator does not belong to this collection."); k_Node lk_Start = new k_Node(null), lk_End = lk_Start; int li_Count = 0; for (k_Iterator lk_Iter = ak_SrcBegin.Clone(); lk_Iter != ak_SrcEnd; lk_Iter.Next(), ++li_Count) { k_Node lk_New = new k_Node(lk_Iter.Current); lk_End.mk_Next = lk_New; lk_New.mk_Prev = lk_End; lk_End = lk_New; } if (li_Count > 0) { PasteNodeRange((k_NodeIterator)ak_Where, lk_Start.mk_Next, lk_End); mi_Count += li_Count; } }
public k_Iterator Erase(k_Iterator ak_First, k_Iterator ak_Last) { if (ak_First == ak_Last) { return(ak_Last.Clone()); } int li_Count = ak_Last - ak_First; k_Node lk_First = ((k_NodeIterator)ak_First).Node; k_Node lk_Last = (ak_Last != this.End) ? ((k_NodeIterator)ak_Last).Node : null; k_Node lk_Node = new k_Node(null, null, mi_HighestNode); k_Node lk_Current = mk_Head; for (int li_Level = mi_HighestNode - 1; li_Level >= 0; --li_Level) { while (lk_Current.Next[li_Level] != null) { if (ComparePos(lk_Current.Next[li_Level], lk_First) >= 0) { break; } lk_Current = lk_Current.Next[li_Level]; } lk_Node.Next[li_Level] = lk_Current; } if (lk_Last == null) { for (int i = 0; i < lk_Node.Height; ++i) { k_Node lk_Left = lk_Node.Next[i]; lk_Left.Next[i] = null; } } else { for (int i = 0; i < lk_Node.Height; ++i) { k_Node lk_Left = lk_Node.Next[i]; // for each level skip over erased range lk_Current = lk_Left.Next[i]; while (lk_Current != null) { if (ComparePos(lk_Current, lk_Last) >= 0) { break; } lk_Current = lk_Current.Next[i]; } lk_Left.Next[i] = lk_Current; } } mi_Count -= li_Count; while (mi_HighestNode > 0 && mk_Head.Next[mi_HighestNode - 1] == null) { --mi_HighestNode; } return(ak_Last); }