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); }
/// <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); }