public void SetWhoIsFirst(Player p = null) { if (p != null) { if (Contains(p)) { GoToNextPlayer(p); } } else { byte i = (byte)new Random().Next(Count); byte j = 0; foreach (var r in _list) { if (j == i) { _current = r; break; } else { j++; } } } }
public bool MoveNext() { if (curr_el == null) { curr_el = _head; } else if (curr_el.Equals(_tail)) { return(false); } else { curr_el = curr_el.Next; } return(true); }
public int Count() { int i = 0; if (_head.Equals(_tail)) { return(1); } CircularLinkedListNode <T> Current = _head; do { i++; Current = Current.Next; }while (!Current.Equals(_head)); return(i); }
public void Add(T value) { CircularLinkedListNode <T> node = new CircularLinkedListNode <T>(value); if (_head == null) { _head = node; _tail = node; _head.Previus = _tail; _tail.Next = _head; } else { _tail.Next = node; node.Previus = _tail; _tail = node; _tail.Next = _head; _head.Previus = _tail; } }
public bool Remove(T value) { CircularLinkedListNode <T> Current = _head; while (Current != null) { if (Current.Value.Equals(value)) { if (_tail.Value.Equals(value) && _head.Value.Equals(value)) { _tail = null; _head = null; } else if (_tail.Value.Equals(value)) { _tail = _tail.Previus; _tail.Next = _head; _head.Previus = _tail; } else if (_head.Value.Equals(value)) { _head = _head.Next; _head.Previus = _tail; _tail.Next = _head; } else { Current.Previus.Next = Current.Next; Current.Next.Previus = Current.Previus; } return(true); } else { Current = Current.Next; } } return(false); }
public bool MoveNext() { if (_enumerator_counter == null) { _enumerator_counter = _current; return(true); } if (Direction.State == TriggerState.DefaultState) { _enumerator_counter = _enumerator_counter.Next; } else { _enumerator_counter = _enumerator_counter.Previus; } if (_enumerator_counter.Equals(_current)) { return(false); } return(true); }
public void GoToNextPlayer(Player p = null) { if (p != null) { foreach (var p_el in _list) { if (p.Equals(p_el.Value)) { _current = p_el; } } return; } if (Direction.State == TriggerState.DefaultState) { _current = _current.Next; } else { _current = _current.Previus; } }
public void Reset() { _enumerator_counter = _current; }
public void Reset() { curr_el = null; }