/** Contains such quantum invariant? */ public boolean contains(QI qi) { long hashCode = qi.getHashCode(); ArrayList<QI> list = _map.get(hashCode); if (list == null) { return false; } else { for (QI aux : list) { if (aux.isEqual(qi)) return true; } return false; } }
/** Returns null if the qi is new to the repository otherwise returns the already stored QI */ public synchronized QI add(QI qi) { long hashCode = qi.getHashCode(); ArrayList<QI> list = _map.get(hashCode); if (list == null) { list = new ArrayList<QI>(); _map.put(hashCode, list); list.add(qi); return null; } else { for (QI aux : list) { if (aux.isEqual(qi)) return aux; } list.add(qi); return null; } }