/// <summary> /// For a variable v, if, according to iv, its value is the same as one of the /// variables kept on the top of stack, remove that value from the top of the stack. /// /// </summary> /// <param name="v"> The variable.</param> /// <param name="iv"> An InitializedVariables data structure, where an EGraph supposedly /// maintains the alias information. /// </param> public void RemoveVar(Variable v, InitializedVariables iv) { if (layers!= null && layers.Count != 0) { HashSet set = (HashSet)layers.Peek(); ArrayList toDelete = new ArrayList(); foreach (Variable u in set) { if (iv.HasSameValue(u, v)) { toDelete.Add(u); } } if (toDelete.Count != 0) { foreach (object o in toDelete) { set.Remove(o); } } } }
/// <summary> /// Whether a value or its alias is contained in a set, according to iv /// /// iv contains alias information. /// </summary> static bool ContainsValueOf(Variable v, InitializedVariables iv, HashSet set) { foreach (Variable u in set) { if (iv.HasSameValue(u, v)) { return true; } } return false; }