public virtual void RemoveItem(T item) { CAssert.Greater(m_size, 0); CAssert.AreSame(this, item.m_list); CFastListNode prev = item.m_listPrev; CFastListNode next = item.m_listNext; if (prev != null) { prev.m_listNext = next; } else { m_listFirst = next; } if (next != null) { next.m_listPrev = prev; } else { m_listLast = prev; } item.m_listNext = item.m_listPrev = null; item.m_list = null; --m_size; }
protected virtual void InsertItem(CFastListNode item, CFastListNode prev, CFastListNode next) { CAssert.IsNull(item.m_list); if (next != null) { next.m_listPrev = item; } else { m_listLast = item; } if (prev != null) { prev.m_listNext = item; } else { m_listFirst = item; } item.m_listPrev = prev; item.m_listNext = next; item.m_list = this; ++m_size; }
public virtual void Clear() { for (CFastListNode t = m_listFirst; t != null;) { CFastListNode next = t.m_listNext; t.m_listPrev = t.m_listNext = null; t.m_list = null; t = next; } m_listFirst = m_listLast = null; m_size = 0; }
public virtual bool ContainsItem(CFastListNode item) { if (item.m_list != this) { return(false); } for (CFastListNode t = m_listFirst; t != null; t = t.m_listNext) { if (t == item) { return(true); } } return(false); }
/* For Unit testing */ public void DetachFromList() { m_list = null; m_listPrev = m_listNext = null; }