// ***** VDMTOOLS START Name=getCells#1|Object KEEP=NO public Set getCells(final Object p) throws CGException { sentinel.entering(((BoardLineSentinel) sentinel).getCells); try { Set res_s_3 = new HashSet(); { Set e1_set_7 = new HashSet(line.values()); Cell c = null; Set tmpSet_21 = new HashSet(e1_set_7); for (Iterator enm_20 = tmpSet_21.iterator(); enm_20.hasNext(); ) { Cell elem_19 = (Cell) enm_20.next(); /* c */ c = elem_19; Boolean pred_8 = null; if ((pred_8 = Boolean.valueOf(!UTIL.equals((c.piece), null))).booleanValue()) pred_8 = Boolean.valueOf(UTIL.equals(((c.piece).belongTo), p)); if (pred_8.booleanValue()) { res_s_3.add(c); } } } return res_s_3; } finally { sentinel.leaving(((BoardLineSentinel) sentinel).getCells); } }
// ***** VDMTOOLS START Name=BoardLine#2|List|Number KEEP=NO public BoardLine(final List cells, final Number yi) throws CGException { vdm_init_BoardLine(); if (!this.pre_BoardLine(cells, yi).booleanValue()) UTIL.RunTime("Precondition failure in BoardLine"); { final Number atom_1 = yi; Map res_m_8 = new HashMap(); { Set e1_set_13 = new HashSet(cells); Set e_set_14 = new HashSet(); e_set_14 = new HashSet(); for (int count_17 = 1; count_17 <= 9; count_17++) e_set_14.add(new Integer(count_17)); Number x = null; Cell cell = null; Set tmpSet_30 = new HashSet(e_set_14); for (Iterator enm_29 = tmpSet_30.iterator(); enm_29.hasNext(); ) { Number elem_28 = UTIL.NumberToInt(enm_29.next()); /* x */ x = elem_28; Set tmpSet_27 = new HashSet(e1_set_13); for (Iterator enm_26 = tmpSet_27.iterator(); enm_26.hasNext(); ) { Cell elem_25 = (Cell) enm_26.next(); /* cell */ cell = elem_25; if ((cell.x).intValue() == x.intValue()) res_m_8.put(x, cell); } } } final Map atom_2 = res_m_8; y = UTIL.NumberToInt(UTIL.clone(atom_1)); line = (Map) UTIL.clone(atom_2); } }
// ***** VDMTOOLS START Name=inv_BoardLine KEEP=NO public Boolean inv_BoardLine() { Boolean rexpr_2 = null; Set var2_5 = new HashSet(); var2_5 = new HashSet(); for (int count_8 = 1; count_8 <= 9; count_8++) var2_5.add(new Integer(count_8)); if ((rexpr_2 = Boolean.valueOf(UTIL.Contains(var2_5, y))).booleanValue()) { Boolean var2_11 = null; Boolean var1_12 = null; if ((var1_12 = Boolean.valueOf(new HashSet(line.keySet()).size() == 9)).booleanValue()) { Set var2_21 = new HashSet(); var2_21 = new HashSet(); for (int count_24 = 1; count_24 <= 9; count_24++) var2_21.add(new Integer(count_24)); var1_12 = Boolean.valueOf(UTIL.equals(new HashSet(line.keySet()), var2_21)); } if ((var2_11 = var1_12).booleanValue()) { Boolean var2_27 = null; boolean tmpQuant_29 = true; { Set e1_set_32 = new HashSet(line.values()); Cell c = null; Set tmpSet_40 = new HashSet(e1_set_32); for (Iterator enm_39 = tmpSet_40.iterator(); enm_39.hasNext() && tmpQuant_29; ) { Cell elem_38 = (Cell) enm_39.next(); /* c */ c = elem_38; if (!((c.y).intValue() == y.intValue())) tmpQuant_29 = false; } } if ((var2_27 = Boolean.valueOf(tmpQuant_29)).booleanValue()) { boolean tmpQuant_43 = false; { Set e1_set_46 = new HashSet(line.values()); Cell c1 = null; Cell c2 = null; Set e_set_60 = e1_set_46; Set tmpSet_63 = new HashSet(e_set_60); for (Iterator enm_62 = tmpSet_63.iterator(); enm_62.hasNext() && !tmpQuant_43; ) { Cell elem_61 = (Cell) enm_62.next(); /* c2 */ c2 = elem_61; Set tmpSet_59 = new HashSet(e1_set_46); for (Iterator enm_58 = tmpSet_59.iterator(); enm_58.hasNext() && !tmpQuant_43; ) { Cell elem_57 = (Cell) enm_58.next(); /* c1 */ c1 = elem_57; Boolean pred_47 = null; if ((pred_47 = Boolean.valueOf(!UTIL.equals(c1, c2))).booleanValue()) pred_47 = Boolean.valueOf((c1.x).intValue() == (c2.x).intValue()); if (pred_47.booleanValue()) tmpQuant_43 = true; } } } var2_27 = Boolean.valueOf(!tmpQuant_43); } var2_11 = var2_27; } rexpr_2 = var2_11; } return rexpr_2; }
// ***** VDMTOOLS START Name=getCell#1|Number KEEP=NO public Cell getCell(final Number r) throws CGException { sentinel.entering(((BoardLineSentinel) sentinel).getCell); try { if (!this.pre_getCell(r).booleanValue()) UTIL.RunTime("Precondition failure in getCell"); return (Cell) line.get(r); } finally { sentinel.leaving(((BoardLineSentinel) sentinel).getCell); } }
// ***** VDMTOOLS START Name=getSeqCellsAux#1|Number KEEP=NO private List getSeqCellsAux(final Number x) throws CGException { sentinel.entering(((BoardLineSentinel) sentinel).getSeqCellsAux); try { if (!this.pre_getSeqCellsAux(x).booleanValue()) UTIL.RunTime("Precondition failure in getSeqCellsAux"); if (x.intValue() == 9) { List tmpSeq_16 = new ArrayList(); tmpSeq_16.add((Cell) line.get(x)); return tmpSeq_16; } else { List rexpr_5 = null; List tmpSeq_7 = new ArrayList(); tmpSeq_7.add((Cell) line.get(x)); rexpr_5 = new ArrayList(tmpSeq_7); rexpr_5.addAll(getSeqCellsAux(new Integer(x.intValue() + 1))); return rexpr_5; } } finally { sentinel.leaving(((BoardLineSentinel) sentinel).getSeqCellsAux); } }
// ***** VDMTOOLS START Name=getEmptyCells KEEP=NO public Set getEmptyCells() throws CGException { sentinel.entering(((BoardLineSentinel) sentinel).getEmptyCells); try { Set res_s_2 = new HashSet(); { Set e1_set_6 = new HashSet(line.values()); Cell c = null; Set tmpSet_14 = new HashSet(e1_set_6); for (Iterator enm_13 = tmpSet_14.iterator(); enm_13.hasNext(); ) { Cell elem_12 = (Cell) enm_13.next(); /* c */ c = elem_12; if (UTIL.equals((c.piece), null)) { res_s_2.add(c); } } } return res_s_2; } finally { sentinel.leaving(((BoardLineSentinel) sentinel).getEmptyCells); } }
// ***** VDMTOOLS START Name=pre_getSeqCellsAux#1|Number KEEP=NO private Boolean pre_getSeqCellsAux(final Number x) throws CGException { Set var2_4 = new HashSet(); var2_4 = new HashSet(); for (int count_7 = 1; count_7 <= 9; count_7++) var2_4.add(new Integer(count_7)); return Boolean.valueOf(UTIL.Contains(var2_4, x)); }