@Test(expectedExceptions = {UnsupportedOperationException.class}) public void testNonViableRemainderCauseZero() { BtrpSet s = new BtrpSet(1, BtrpOperand.Type.NUMBER); s.remainder(new BtrpNumber(0, BtrpNumber.Base.BASE_10)); }
@Override public BtrpSet remainder(BtrpOperand other) { if (other instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) other; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int size = x.getIntValue(); if (size == 0) { throw new UnsupportedOperationException("cannot split into empty subsets"); } BtrpSet res = new BtrpSet(degree + 1, t); res.t = t; BtrpSet s = new BtrpSet(degree, t); s.t = t; res.add(s); for (Iterator<BtrpOperand> ite = values.iterator(); ite.hasNext(); ) { BtrpOperand v = ite.next(); s.add(v); if (s.size() == size && ite.hasNext()) { s = new BtrpSet(degree, t); res.add(s); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet remainder(BtrpOperand other) { if (other instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) other; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int size = x.getIntValue(); if (size == 0) { throw new UnsupportedOperationException("cannot split into empty subsets"); } BtrpSet res = new BtrpSet(degree + 1, t); res.t = t; BtrpSet s = new BtrpSet(degree, t); s.t = t; res.add(s); for (Iterator<BtrpOperand> ite = values.iterator(); ite.hasNext(); ) { BtrpOperand v = ite.next(); s.add(v); if (s.size() == size && ite.hasNext()) { s = new BtrpSet(degree, t); res.add(s); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet remainder(BtrpOperand other) { if (other instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) other; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int size = x.getIntValue(); if (size == 0) { throw new UnsupportedOperationException("cannot split into empty subsets"); } BtrpSet res = new BtrpSet(degree + 1, t); res.t = t; BtrpSet s = new BtrpSet(degree, t); s.t = t; res.add(s); for (Iterator<BtrpOperand> ite = values.iterator(); ite.hasNext(); ) { BtrpOperand v = ite.next(); s.add(v); if (s.size() == size && ite.hasNext()) { s = new BtrpSet(degree, t); res.add(s); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } BtrpSet(int d, Type ty); }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet remainder(BtrpOperand other) { if (other instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) other; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int size = x.getIntValue(); if (size == 0) { throw new UnsupportedOperationException("cannot split into empty subsets"); } BtrpSet res = new BtrpSet(degree + 1, t); res.t = t; BtrpSet s = new BtrpSet(degree, t); s.t = t; res.add(s); for (Iterator<BtrpOperand> ite = values.iterator(); ite.hasNext(); ) { BtrpOperand v = ite.next(); s.add(v); if (s.size() == size && ite.hasNext()) { s = new BtrpSet(degree, t); res.add(s); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } BtrpSet(int d, Type ty); @Override Type type(); @Override BtrpSet plus(BtrpOperand s); @Override BtrpSet minus(BtrpOperand s); int size(); @Override int degree(); @Override BtrpSet remainder(BtrpOperand other); @Override BtrpSet div(BtrpOperand nb); @Override BtrpSet times(BtrpOperand s); @Override BtrpSet power(BtrpOperand nb); @Override String toString(); @Override BtrpSet copy(); @Override boolean equals(Object o); @Override BtrpNumber eq(BtrpOperand other); @Override int hashCode(); List<BtrpOperand> getValues(); }
BtrpSet extends DefaultBtrpOperand { @Override public BtrpSet remainder(BtrpOperand other) { if (other instanceof BtrpNumber) { BtrpNumber x = (BtrpNumber) other; if (!x.isInteger()) { throw new UnsupportedOperationException("Integer divider expected"); } int size = x.getIntValue(); if (size == 0) { throw new UnsupportedOperationException("cannot split into empty subsets"); } BtrpSet res = new BtrpSet(degree + 1, t); res.t = t; BtrpSet s = new BtrpSet(degree, t); s.t = t; res.add(s); for (Iterator<BtrpOperand> ite = values.iterator(); ite.hasNext(); ) { BtrpOperand v = ite.next(); s.add(v); if (s.size() == size && ite.hasNext()) { s = new BtrpSet(degree, t); res.add(s); } } return res; } throw new UnsupportedOperationException("Integer divider expected"); } BtrpSet(int d, Type ty); @Override Type type(); @Override BtrpSet plus(BtrpOperand s); @Override BtrpSet minus(BtrpOperand s); int size(); @Override int degree(); @Override BtrpSet remainder(BtrpOperand other); @Override BtrpSet div(BtrpOperand nb); @Override BtrpSet times(BtrpOperand s); @Override BtrpSet power(BtrpOperand nb); @Override String toString(); @Override BtrpSet copy(); @Override boolean equals(Object o); @Override BtrpNumber eq(BtrpOperand other); @Override int hashCode(); List<BtrpOperand> getValues();  }