Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/UndoSystem/CollectionRemoveAction.cs @ 13757

Last change on this file since 13757 was 12503, checked in by aballeit, 10 years ago

#2283 added GUI and charts; fixed MCTS

File size: 806 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace Microsoft.Research.DynamicDataDisplay.Common.UndoSystem
7{
8  public sealed class CollectionRemoveAction<T> : UndoAction
9  {
10    private readonly IList<T> collection;
11    private readonly T item;
12    private readonly int index;
13
14    public CollectionRemoveAction(IList<T> collection, T item, int index)
15    {
16      if (collection == null)
17        throw new ArgumentNullException("collection");
18      if (item == null)
19        throw new ArgumentNullException("addedItem");
20
21      this.collection = collection;
22      this.item = item;
23      this.index = index;
24    }
25
26    public override void Do()
27    {
28      collection.Remove(item);
29    }
30
31    public override void Undo()
32    {
33      collection.Insert(index, item);
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.