package ua.ansymo.hintco

import java.util.HashMap
import java.util.LinkedList
import java.util.Set

class ConstraintsStack extends LinkedList<HashMap<PrecedenceNode, Set<PrecedenceNode>>> {
	
	def stackContains(PrecedenceNode k, PrecedenceNode v){
		for (m : this) {
			if (m.containsKey(k) && m.get(k).contains(v)){
				return true
			}
		}
		return false
	}
	
	def safeAdd(PrecedenceNode k, PrecedenceNode v){
		if (! this.peek().containsKey(k) ){
			this.peek().put(k, newHashSet())
		}
		this.peek().get(k).add(v)
	}
	
}