public override bool Equals(object obj) { NodeHashMapKey other = obj as NodeHashMapKey; if (other == null) { return(false); } return(other.left == left && other.right == right); }
public int lookup(NodeType op, int i1, int i2) { sharp_assert(op == NodeType.AND || op == NodeType.XOR); //1. left input always has smaller index than right if (i1 > i2) { int temp = i1; i1 = i2; i2 = temp; } //2. For XOR gate, always require both inputs not negated bool do_NEGATE = false; if (op == NodeType.XOR) { if (IS_NEGATED(i1)) { i1 = NEGATE(i1); do_NEGATE = !do_NEGATE; } if (IS_NEGATED(i2)) { i2 = NEGATE(i2); do_NEGATE = !do_NEGATE; } } //3. put special mark on the XOR node int l, r; l = i1; r = i2; if (op == NodeType.XOR) { l += XOR_MARK; } //4. Lookup NodeHashMapKey key = new NodeHashMapKey(l, r); // ulong key = ((ulong)l << 32) + (ulong) r; object item = hash_table[key]; if (item == null) { return(INVALID); } int o = (int)item; if (do_NEGATE) { o = NEGATE(o); } return(o); }
public void insert(int n, NodeType op, int i1, int i2) { sharp_assert(op == NodeType.AND || op == NodeType.XOR); sharp_assert(i1 < i2); sharp_assert(!((op == NodeType.XOR) && (IS_NEGATED(i1) || IS_NEGATED(i2)))); sharp_assert(!IS_NEGATED(n)); int l, r; l = i1; r = i2; if (op == NodeType.XOR) { l += XOR_MARK; } NodeHashMapKey key = new NodeHashMapKey(l, r); // ulong key = ((ulong)l << 32) + (ulong) r; sharp_assert(!hash_table.Contains(key)); hash_table[key] = n; }
public void remove(int n, NodeType op, int i1, int i2) { sharp_assert(op == NodeType.AND || op == NodeType.XOR); sharp_assert(i1 < i2); sharp_assert(!((op == NodeType.XOR) && (IS_NEGATED(i1) || IS_NEGATED(i2)))); sharp_assert(!IS_NEGATED(n)); //put special mark on the XOR node int l, r; l = i1; r = i2; if (op == NodeType.XOR) { l += XOR_MARK; } NodeHashMapKey key = new NodeHashMapKey(l, r); // ulong key = ((ulong)l << 32) + (ulong) r; sharp_assert((int)hash_table[key] == n); hash_table.Remove(key); }