Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/UndoSystem/CollectionAddAction.cs @ 12503

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

#2283 added GUI and charts; fixed MCTS

File size: 736 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 CollectionAddAction<T> : UndoAction
9  {
10    private readonly ICollection<T> collection;
11    private readonly T item;
12
13    public CollectionAddAction(ICollection<T> collection, T item)
14    {
15      if (collection == null)
16        throw new ArgumentNullException("collection");
17      if (item == null)
18        throw new ArgumentNullException("addedItem");
19
20      this.collection = collection;
21      this.item = item;
22    }
23
24    public override void Do()
25    {
26      collection.Add(item);
27    }
28
29    public override void Undo()
30    {
31      collection.Remove(item);
32    }
33  }
34}
Note: See TracBrowser for help on using the repository browser.