public void add(N item) { if (count == 0) { first.Member = last.Member = item; first.Next = last.Next = null; } else { last.Next = new turn <N>(item); last = last.Next; } count++; }
public int IndexOf(N item) { turn <N> temp = first; for (int i = 0; i < count; i++) { if (temp.Member.Equals(item)) { return(i); } temp = temp.Next; } return(-1); }
public N this[int index] { get{ if (index < count) { turn <N> temp_member = first; for (int i = 0; i < index; i++) { temp_member = temp_member.Next; } return(temp_member.Member); } else { throw new ArgumentException(); } } }
public void remove(N item) { if (count > 1) { turn <N> temp = first; while (temp.Next != null) { if (temp.Next.Member.Equals(item)) { temp.Next = temp.Next.Next; count--; } } } else { if ((first.Member.Equals(item)) && (count == 1)) { first = last = null; count = 0; } } }
public collection() { first = null; last = null; count = 0; }
public turn(N _member) { member = _member; next = null; }