/// <summary> /// Walks the queue calling back to the specified delegate for /// each populated index in the queue. /// </summary> private void WalkDeque(DequeWalker walker) { if (_itemCnt != 0) { int end; if (_head >= _tail) { end = _data.Length; } else { end = _tail; } for (int i = _head; i < end; i++) { if (!walker(i)) { return; } } if (_head >= _tail) { for (int i = 0; i < _tail; i++) { if (!walker(i)) { return; } } } } }
/// <summary> /// Walks the queue calling back to the specified delegate for /// each populated index in the queue. /// </summary> private bool WalkDeque(DequeWalker walker) { if (_itemCnt != 0) { // capture these at the start so we can mutate int head = _head; int tail = _tail; int end; if (head >= tail) { end = _data.Length; } else { end = tail; } for (int i = head; i < end; i++) { if (!walker(i)) { return(false); } } if (head >= tail) { for (int i = 0; i < tail; i++) { if (!walker(i)) { return(false); } } } } return(true); }
/// <summary> /// Walks the queue calling back to the specified delegate for /// each populated index in the queue. /// </summary> private void WalkDeque(DequeWalker walker) { if (itemCnt != 0) { int end; if (head > tail) { end = data.Length; } else if (head == tail) { end = data.Length; } else { end = tail; } for (int i = head; i < end; i++) { if (!walker(i)) { return; } } if (head >= tail) { for (int i = 0; i < tail; i++) { if (!walker(i)) { return; } } } } }