/// <summary> /// Enqueues the command specified and makes it the current command. /// </summary> /// <param name="toEnqueue">To enqueue.</param> /// <returns>true if enqueue action succeeded, false otherwise</returns> public bool EnqueueCommand(CommandBase toEnqueue) { ArgumentVerifier.CantBeNull(toEnqueue, "toEnqueue"); if (CommandQueueManagerSingleton.GetInstance().IsInUndoablePeriod) { // ignore, all commands are already there in this mode and this command therefore already is either there or is not important return(false); } if (this.UndoInProgress) { if (CommandQueueManager.ThrowExceptionOnDoDuringUndo) { // can't add new commands to a queue of a command which executed an undoFunc. This happens through bugs in the using code so we have to // thrown an exception to illustrate that there's a problem with the code using this library. throw new DoDuringUndoException(); } // ignore return(false); } // clear queue from the active index if (_currentCommandBucket == null) { // clear the complete queue from any commands which might have been undone, as the new command makes them unreachable. _commands.Clear(); } else { _commands.RemoveAfter(_currentCommandBucket); } _commands.InsertAfter(new ListBucket <CommandBase>(toEnqueue), _currentCommandBucket); return(true); }
/// <summary> /// Clears all elements from the heap /// </summary> public override void Clear() { _trees.Clear(); _heapRoot = null; _count = 0; }