private void CheckVersion() { if (version != queue.version) { Thrower.InvalidOperationException(Resources.InvalidOperation_EnumCorrupt); } }
/// <summary> /// Returns the object at the beginning of the <see cref="T:Academy.Collections.Generic.EndlessQueue`1"/> without removing it. /// </summary> /// <returns>The object at the beginning of the <see cref="T:Academy.Collections.Generic.EndlessQueue`1"/>.</returns> public T Peek() { if (count == 0) { Thrower.InvalidOperationException(Resources.InvalidOperation_EmptyCollection); } return(items[head]); }
/// <summary> /// Gets the maximum priority element contained in the <see cref="T:Academy.Collections.Generic.PriorityQueue`1"/> without removing it. /// </summary> /// <returns>Returns the object at the beginning of the <see cref="T:Academy.Collections.Generic.PriorityQueue`1"/></returns> public T Peek() { if (_currentIndex == 1) { Thrower.InvalidOperationException(Resources.InvalidOperation_EmptyCollection); } return(_elements[1]); }
void IEnumerator.Reset() { if (_version != _heap._version) { Thrower.InvalidOperationException(Resources.InvalidOperation_EnumCorrupt); } _index = 0; _current = default(T); }
/// <summary> /// Removes and returns the object at the beginning of the <see cref="T:Academy.Collections.Generic.EndlessQueue`1"/>. /// </summary> /// <returns>The object that is removed from the beginning of the <see cref="T:Academy.Collections.Generic.EndlessQueue`1"/>.</returns> public T Dequeue() { if (count == 0) { Thrower.InvalidOperationException(Resources.InvalidOperation_EmptyCollection); } T item = this.items[head]; head = (head + 1) % items.Length; count--; version++; return(item); }
/// <summary> /// Advances the enumerator to the next element of the <see cref="T:Academy.Collections.Generic.PriorityQueue`1"/> /// </summary> /// <returns></returns> public bool MoveNext() { if (_version != _heap._version) { Thrower.InvalidOperationException(Resources.InvalidOperation_EnumCorrupt); } if (_clone.Count > 0) { _current = _clone.Dequeue(); _index++; return(true); } _index = _heap.Count + 1; return(false); }
private void CheckIndexConsistence() { if (isRow) { if (matrix.RowCount <= containedIndex) { Thrower.InvalidOperationException(Resources.InvalidOperation_RowIndex); } } else { if (matrix.ColumnCount <= containedIndex) { Thrower.InvalidOperationException(Resources.InvalidOperation_ColumnIndex); } } }
/// <summary> /// Removes and returns the maximum priority element contained in the <see cref="T:Academy.Collections.Generic.PriorityQueue`1"/>. /// </summary> /// <returns>Returns the maximum priority element contained in the <see cref="T:Academy.Collections.Generic.PriorityQueue`1"/></returns> public T Dequeue() { if (_currentIndex == 1) { Thrower.InvalidOperationException(Resources.InvalidOperation_EmptyCollection); } T local = _elements[1]; if (Count > 1) { Swap(1, _currentIndex - 1); _currentIndex--; Heapify(1); } else { Clear(); } _version++; return(local); }
/// <summary> /// Thrown when enumerator and underlying collection does not share 'VERSION' field. /// </summary> internal static void EnumeratorCorrupted() { Thrower.InvalidOperationException(Resources.InvalidOperation_EnumCorrupt); }