/*======================================================================== Copyright (C) 2006 by Geir-Tore Lindsve, Torbjørn Meistad and Yngve Raudberget, hereby refered to as "the authors". All rights reserved Permission is hereby granted, without written agreement and without license or royalty fees, to use, reproduce, prepare derivative works, distribute, and display this software and its documentation for NONCOMMERCIAL RESEARCH AND EDUCATIONAL PURPOSES, provided that (1) the above copyright notice and the following two paragraphs appear in all copies of the source code and (2) redistributions, including without limitation binaries, reproduce these notices in the supporting documentation. IN NO EVENT SHALL THE AUTHORS, OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. ========================================================================*/ using System; using System.Collections.Generic; using System.Collections; using System.Text; using Iesi.Collections; namespace Casper.Algorithm { /// /// Class for keeping track of which variable removed which values /// from the domain of this variable. This is used under resetting the variable's /// domain when backtracking, so that we are sure we only reset the domain /// to the values removed by the /// public class RemovedValues { private Hashtable remValStructure; /// /// Initializes a new instance of the class. /// public RemovedValues() { remValStructure = new Hashtable(); } /// /// Gets or sets the removed values structure. /// /// The removed values structure. public Hashtable RemValStructure { get { return remValStructure; } set { remValStructure = value; } } /// /// Inserts the specified removed value. The key is the specified variable. /// /// The removed value. /// The variable. public void Insert(int removedValue,LookAheadVarDom var) { if (remValStructure[var] == null) { remValStructure[var] = new HybridSet(); } HybridSet remValList = (HybridSet)RemValStructure[var]; remValList.Add(removedValue); //this also updates the the set in the hastable at the key of var } /// /// Sets the value at key "var" in the remValStructure to be null. /// /// The variable public void Remove(LookAheadVarDom var) { remValStructure[var]=null; } /// /// Clears the removed value structure. /// public void Clear() { remValStructure = new Hashtable(); } } }