@Override public SemiSparseMutableIntSet make() { return new SemiSparseMutableIntSet(); }
@Override public SemiSparseMutableIntSet make() { return new SemiSparseMutableIntSet(); }
@Override public SemiSparseMutableIntSet make() { return new SemiSparseMutableIntSet(); }
@Override public SemiSparseMutableIntSet makeCopy(IntSet x) { SemiSparseMutableIntSet y = new SemiSparseMutableIntSet(); y.copySet(x); return y; }
@Override public SemiSparseMutableIntSet makeCopy(IntSet x) { SemiSparseMutableIntSet y = new SemiSparseMutableIntSet(); y.copySet(x); return y; }
@Override public SemiSparseMutableIntSet makeCopy(IntSet x) { SemiSparseMutableIntSet y = new SemiSparseMutableIntSet(); y.copySet(x); return y; }
/** * @throws IllegalArgumentException if set is null */ @Override public SemiSparseMutableIntSet make(int[] set) { if (set == null) { throw new IllegalArgumentException("set is null"); } if (set.length == 0) { return make(); } else { // XXX not very efficient. TreeSet<Integer> T = new TreeSet<>(); for (int element : set) { T.add(Integer.valueOf(element)); } SemiSparseMutableIntSet result = new SemiSparseMutableIntSet(); for (Integer I : T) { result.add(I.intValue()); } return result; } }
@Override public IntSet union(IntSet that) { SemiSparseMutableIntSet temp = new SemiSparseMutableIntSet(); temp.addAll(this); temp.addAll(that); return temp; }
/** * @throws IllegalArgumentException if set is null */ @Override public SemiSparseMutableIntSet make(int[] set) { if (set == null) { throw new IllegalArgumentException("set is null"); } if (set.length == 0) { return make(); } else { // XXX not very efficient. TreeSet<Integer> T = new TreeSet<>(); for (int element : set) { T.add(Integer.valueOf(element)); } SemiSparseMutableIntSet result = new SemiSparseMutableIntSet(); for (Integer I : T) { result.add(I.intValue()); } return result; } }
@Override public SemiSparseMutableIntSet parse(String string) throws NumberFormatException { int[] data = SparseIntSet.parseIntArray(string); SemiSparseMutableIntSet result = new SemiSparseMutableIntSet(); for (int element : data) result.add(element); return result; }
@Override public SemiSparseMutableIntSet parse(String string) throws NumberFormatException { int[] data = SparseIntSet.parseIntArray(string); SemiSparseMutableIntSet result = new SemiSparseMutableIntSet(); for (int element : data) result.add(element); return result; }
@Override public IntSet union(IntSet that) { SemiSparseMutableIntSet temp = new SemiSparseMutableIntSet(); temp.addAll(this); temp.addAll(that); return temp; }
@Override public IntSet union(IntSet that) { SemiSparseMutableIntSet temp = new SemiSparseMutableIntSet(); temp.addAll(this); temp.addAll(that); return temp; }
@Override public SemiSparseMutableIntSet parse(String string) throws NumberFormatException { int[] data = SparseIntSet.parseIntArray(string); SemiSparseMutableIntSet result = new SemiSparseMutableIntSet(); for (int element : data) result.add(element); return result; }
/** * @throws IllegalArgumentException if set is null */ @Override public SemiSparseMutableIntSet make(int[] set) { if (set == null) { throw new IllegalArgumentException("set is null"); } if (set.length == 0) { return make(); } else { // XXX not very efficient. TreeSet<Integer> T = new TreeSet<>(); for (int element : set) { T.add(Integer.valueOf(element)); } SemiSparseMutableIntSet result = new SemiSparseMutableIntSet(); for (Integer I : T) { result.add(I.intValue()); } return result; } }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } SemiSparseMutableIntSet newThis = new SemiSparseMutableIntSet(); for (IntIterator bits = intIterator(); bits.hasNext();) { int bit = bits.next(); if (that.contains(bit)) { newThis.add(bit); } } return newThis; }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } SemiSparseMutableIntSet newThis = new SemiSparseMutableIntSet(); for (IntIterator bits = intIterator(); bits.hasNext();) { int bit = bits.next(); if (that.contains(bit)) { newThis.add(bit); } } return newThis; }
/** * This implementation must not despoil the original value of "this" * * @return a new IntSet which is the intersection of this and that */ @Override public IntSet intersection(IntSet that) { if (that == null) { throw new IllegalArgumentException("null that"); } SemiSparseMutableIntSet newThis = new SemiSparseMutableIntSet(); for (IntIterator bits = intIterator(); bits.hasNext();) { int bit = bits.next(); if (that.contains(bit)) { newThis.add(bit); } } return newThis; }
@Test public void testCase1() { final SemiSparseMutableIntSet ssmIntSet = new SemiSparseMutableIntSet(); ssmIntSet.add(1); final SemiSparseMutableIntSet ssmIntSet2 = SemiSparseMutableIntSet.diff(ssmIntSet, ssmIntSet); ssmIntSet2.max(); }
@Test public void testSpecificBugsInSemiSparseMutableIntSets() { SemiSparseMutableIntSet v1 = new SemiSparseMutableIntSet(); v1.add(54); v1.add(58); v1.add(59); v1.add(64); v1.add(67); v1.add(73); v1.add(83); v1.add(105); v1.add(110); v1.add(126); v1.add(136); v1.add(143); v1.add(150); v1.add(155); v1.add(156); v1.add(162); v1.add(168); v1.add(183); v1.add(191); v1.add(265); v1.add(294); v1.add(324); v1.add(344); v1.add(397); } }