internal IntrusiveIterator(IntrusiveCollection <E> _enclosing) { this._enclosing = _enclosing; // + IntrusiveCollection.this + "]"; this.cur = this._enclosing.root; this.next = null; }
public void SetNext <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element next) where _T0 : IntrusiveCollection.Element { Preconditions.CheckState(list == this._enclosing._enclosing); this.first = next; }
public void SetPrev <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element prev) where _T0 : IntrusiveCollection.Element { Preconditions.CheckState(list == this._enclosing._enclosing); this.last = prev; }
public void SetPrev <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element prev) where _T0 : IntrusiveCollection.Element { // IntrusiveCollection.Element System.Diagnostics.Debug.Assert(list == pool.GetDirectiveList()); this.prev = prev; }
public void SetNext <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element next) where _T0 : IntrusiveCollection.Element { // IntrusiveCollection.Element System.Diagnostics.Debug.Assert(list == pool.GetDirectiveList()); this.next = next; }
public override bool HasNext() { if (this.next == null) { this.next = this.cur.GetNext(this._enclosing._enclosing); } return(this.next != this._enclosing.root); }
public void RemoveInternal <_T0>(IntrusiveCollection <_T0> list) where _T0 : IntrusiveCollection.Element { // IntrusiveCollection.Element System.Diagnostics.Debug.Assert(list == pool.GetDirectiveList()); this.pool = null; this.prev = null; this.next = null; }
public override void Remove() { if (this.cur == null) { throw new InvalidOperationException("Already called remove " + "once on this element." ); } this.next = this._enclosing.RemoveElement(this.cur); this.cur = null; }
// // IntrusiveCollection.Element implementation // public void InsertInternal <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element prev, IntrusiveCollection.Element next) where _T0 : IntrusiveCollection.Element { // IntrusiveCollection.Element System.Diagnostics.Debug.Assert(this.pool == null); this.pool = ((CachePool.DirectiveList)list).GetCachePool(); this.prev = prev; this.next = next; }
private IntrusiveCollection.Element RemoveElement(IntrusiveCollection.Element elem ) { IntrusiveCollection.Element prev = elem.GetPrev(this); IntrusiveCollection.Element next = elem.GetNext(this); elem.RemoveInternal(this); prev.SetNext(this, next); next.SetPrev(this, prev); size--; return(next); }
public virtual bool Contains(object o) { try { IntrusiveCollection.Element element = (IntrusiveCollection.Element)o; return(element.IsInList(this)); } catch (InvalidCastException) { return(false); } }
public override E Next() { if (this.next == null) { this.next = this.cur.GetNext(this._enclosing._enclosing); } if (this.next == this._enclosing.root) { throw new NoSuchElementException(); } this.cur = this.next; this.next = null; return((E)this.cur); }
public virtual bool RetainAll <_T0>(ICollection <_T0> collection) { bool changed = false; for (IEnumerator <E> iter = GetEnumerator(); iter.HasNext();) { IntrusiveCollection.Element elem = iter.Next(); if (!collection.Contains(elem)) { iter.Remove(); changed = true; } } return(changed); }
public void SetNext <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element next) where _T0 : IntrusiveCollection.Element { for (int i = 0; i < triplets.Length; i += 3) { if (triplets[i] == list) { triplets[i + 2] = next; return; } } throw new RuntimeException("Called setNext on an element that wasn't " + "in the list." ); }
public virtual bool Remove(object o) { try { IntrusiveCollection.Element elem = (IntrusiveCollection.Element)o; if (!elem.IsInList(this)) { return(false); } RemoveElement(elem); return(true); } catch (InvalidCastException) { return(false); } }
/// <summary>Add an element to the front of the list.</summary> /// <param name="elem">The new element to add.</param> public virtual bool AddFirst(IntrusiveCollection.Element elem) { if (elem == null) { return(false); } if (elem.IsInList(this)) { return(false); } IntrusiveCollection.Element next = root.GetNext(this); next.SetPrev(this, elem); root.SetNext(this, elem); elem.InsertInternal(this, root, next); size++; return(true); }
/// <summary>Add an element to the end of the list.</summary> /// <param name="elem">The new element to add.</param> public virtual bool AddItem(E elem) { if (elem == null) { return(false); } if (elem.IsInList(this)) { return(false); } IntrusiveCollection.Element prev = root.GetPrev(this); prev.SetNext(this, elem); root.SetPrev(this, elem); elem.InsertInternal(this, prev, root); size++; return(true); }
public void InsertInternal <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element prev, IntrusiveCollection.Element next) where _T0 : IntrusiveCollection.Element { for (int i = 0; i < triplets.Length; i += 3) { if (triplets[i] == list) { throw new RuntimeException("Trying to re-insert an element that " + "is already in the list." ); } } object[] newTriplets = Arrays.CopyOf(triplets, triplets.Length + 3); newTriplets[triplets.Length] = list; newTriplets[triplets.Length + 1] = prev; newTriplets[triplets.Length + 2] = next; triplets = newTriplets; }
public IntrusiveCollection() { root = new _Element_89(this); }
// We keep references to the first and last elements for easy access. public void InsertInternal <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element prev, IntrusiveCollection.Element next) where _T0 : IntrusiveCollection.Element { throw new RuntimeException("Can't insert root element"); }