<commit_before>﻿//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 <NAME> (http://www.antigrain.com)
//
// C# port by: <NAME>
//                  <EMAIL>
// Copyright (C) 2007
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: <EMAIL>
//          <EMAIL>
//          http://www.antigrain.com
//----------------------------------------------------------------------------
using System.Collections.Generic;

namespace MatterHackers.Agg.UI
{
	public class UndoBuffer
	{
		private Stack<IUndoRedoCommand> redoBuffer = new Stack<IUndoRedoCommand>();

		private Stack<IUndoRedoCommand> undoBuffer = new Stack<IUndoRedoCommand>();

		public UndoBuffer()
		{
		}

		public void Add(IUndoRedoCommand command)
		{
			undoBuffer.Push(command);
			redoBuffer.Clear();
		}

		public void Redo(int redoCount = 1)
		{
			for (int i = 1; i <= redoCount; i++)
			{
				if (redoBuffer.Count != 0)
				{
					IUndoRedoCommand command = redoBuffer.Pop();
					command.Do();
					undoBuffer.Push(command);
				}
			}
		}

		public void Undo(int undoCount = 1)
		{
			for (int i = 1; i <= undoCount; i++)
			{
				if (undoBuffer.Count != 0)
				{
					IUndoRedoCommand command = undoBuffer.Pop();
					command.Undo();
					redoBuffer.Push(command);
				}
			}
		}

		internal void ClearHistory()
		{
			undoBuffer.Clear();
			redoBuffer.Clear();
		}
	}

	public interface IUndoRedoCommand<commit_msg>Put in undo redo counts and notifications.<commit_after>﻿//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 <NAME> (http://www.antigrain.com)
//
// C# port by: <NAME>
//                  <EMAIL>
// Copyright (C) 2007
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: <EMAIL>
//          <EMAIL>
//          http://www.antigrain.com
//----------------------------------------------------------------------------
using System;
using System.Collections.Generic;

namespace MatterHackers.Agg.UI
{
	public class UndoBuffer
	{
		private Stack<IUndoRedoCommand> redoBuffer = new Stack<IUndoRedoCommand>();
		public int RedoCount { get { return redoBuffer.Count; } }

		private Stack<IUndoRedoCommand> undoBuffer = new Stack<IUndoRedoCommand>();
		public int UndoCount { get { return undoBuffer.Count; } }

		public event EventHandler Changed;

		public UndoBuffer()
		{
		}

		public void Add(IUndoRedoCommand command)
		{
			undoBuffer.Push(command);
			redoBuffer.Clear();
			Changed?.Invoke(this, null);
        }

		public void Redo(int redoCount = 1)
		{
			for (int i = 1; i <= redoCount; i++)
			{
				if (redoBuffer.Count != 0)
				{
					IUndoRedoCommand command = redoBuffer.Pop();
					command.Do();
					undoBuffer.Push(command);
				}
			}
			Changed?.Invoke(this, null);
		}

		public void Undo(int undoCount = 1)
		{
			for (int i = 1; i <= undoCount; i++)
			{
				if (undoBuffer.Count != 0)
				{
					IUndoRedoCommand command = undoBuffer.Pop();
					command.Undo();
					redoBuffer.Push(command);
				}
			}
			Changed?.Invoke(this, null);
		}

		internal void ClearHistory()
		{
			undoBuffer.Clear();
			redoBuffer.Clear();
			Changed?.Invoke(this, null);
		}
	}

	public interface IUndoRedoCommand
{'fraction_non_alphanumeric': 0.2313986192789568, 'fraction_numerical': 0.010227563283047815, 'mean_word_length': 1.865934065934066, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5189976', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1141, 'n_words': 305}