import java.util.*;
import java.io.*;

import edu.mit.six825.bn.functiontable.*;

/**
 * A wrapper for the Assignment objects we were given, because their
 * equals() and hashCode() methods render them totally inappropriate
 * for use as HashMap keys.
 *
 * @author nocturne
 */
public class HashableAssignment {
    public Assignment ass;
    public String stringrep;
    private int hashval;

    public HashableAssignment(Assignment _ass) {
	ass = _ass;
	// Cache these because we can. Seems to help a *tiny* bit.
	stringrep = ass.toString();
	hashval = stringrep.hashCode();
    }

    public String toString() {
	return(stringrep);
    }

    public int hashCode() {
	return (hashval);
    }

    public boolean equals(final Object obj) {
	if (obj instanceof HashableAssignment) {
	    HashableAssignment ha = (HashableAssignment) obj;
	    if (stringrep.equals(ha.stringrep)) {
		return (true);
	    }
	}
	return(false);
    }
}    
