/** * Wraps a {@link BinaryMatrix} instance with a {@link PairSet} instance. * * <p><b>NOTE:</b> the maximum item and transaction IDs are those existing in the binary matrix * when the wrapping take place * * @param b a {@link BinaryMatrix} instance to wrap * @return a new {@link PairSet} instance, indexed by the given matrix */ public static PairSet<Integer, Integer> createFromBinaryMatrix(BinaryMatrix b) { // TODO this is a little bit costly since PairSet will allocate an array // and a HashMap of Integers to map elements of BinaryMatrix... // Think about a IntegerPairSet class or to an "fake" IntegerIndexedSet // just for this purpose. IntegerSet t = new IntegerSet(b.emptyRow()); t.intSet().add(b.maxRow() + 1); t.intSet().complement(); IntegerSet i = new IntegerSet(b.emptyRow()); i.intSet().add(b.maxCol() + 1); i.intSet().complement(); return new PairSet<Integer, Integer>(b, t, i); }