/// <Docs>The item to remove from the current collection.</Docs> /// <para>Removes the first occurrence of an item from the current collection.</para> /// <summary> /// Remove the specified item. /// </summary> /// <param name="item">Item.</param> public bool Remove(TData item) { MultiThreadedListItem cur = this.first, prv = null; while (cur != null) { if (Object.Equals(cur.Data, item)) { MultiThreadedListItem nxt = cur.Next; if (prv != null) { prv.Next = nxt; } else { this.first = nxt; } if (nxt == null) { this.last = prv; } this.count--; return(true); } prv = cur; cur = cur.Next; } return(false); }
/// <summary> /// Gets an enumerator to enumerate over the entire collection. /// </summary> /// <returns>An <see cref="T:IEnumerator`1"/> instance that iterates over all the items stored in the collection.</returns> /// <remarks> /// <para>The <see cref="T:MultiThreadedList`1"/> allows multiple iterations at once and while an <see cref="T:IEnumerator`1"/> is iterating /// adding additional elements is allowed that are immediately visible to the other active <see cref="T:IEnumerator`1"/> instances.</para> /// </remarks> public IEnumerator <TData> GetEnumerator() { MultiThreadedListItem cur = this.first; while (cur != null) { yield return(cur.Data); cur = cur.Next; } }
/// <Docs>The item to add to the current collection.</Docs> /// <para>Adds an item to the current collection.</para> /// <remarks>To be added.</remarks> /// <exception cref="System.NotSupportedException">The current collection is read-only.</exception> /// <summary> /// Add the specified item. /// </summary> /// <param name="item">Item.</param> public void Add(TData item) { MultiThreadedListItem mtli = new MultiThreadedListItem(item); this.count++; if (this.last == null) { this.first = this.last = mtli; } else { this.last.Next = mtli; this.last = mtli; } }
/// <summary> /// Remove all the data from the entire collection. /// </summary> public void Clear() { this.first = null; this.last = null; this.count = 0x00; }