/// <summary> /// Helper method to get the next unit to redo, or throw an <see cref="InvalidOperationException"/>. /// </summary> /// <typeparam name="T">The type of undo units.</typeparam> /// <param name="buffer">The <see cref="UndoUnitBuffer{T}"/>.</param> /// <returns>The next unit to redo.</returns> /// <remarks> /// This is a <c>O(1)</c> operation in time complexity. /// </remarks> /// <exception cref="InvalidOperationException">If there are no more units to redo.</exception> public static T GetNextToRedo <T>(this UndoUnitBuffer <T> buffer) { T retVal; if (!buffer.TryGetNextToRedo(out retVal)) { buffer.ThrowUnderflow(false); } return(retVal); }
/// <summary> /// Helper method to check whether given <see cref="UndoUnitBuffer{T}"/> can perform an redo operation. /// </summary> /// <typeparam name="T">The type of undo units.</typeparam> /// <param name="buffer">The <see cref="UndoUnitBuffer{T}"/>.</param> /// <returns><c>true</c> if <paramref name="buffer"/> is in such state that redo operation is possible; <c>false</c> otherwise.</returns> /// <remarks> /// This is a <c>O(1)</c> operation in time complexity. /// </remarks> public static Boolean CanRedo <T>(this UndoUnitBuffer <T> buffer) { T dummy; return(buffer.TryGetNextToRedo(out dummy)); }