Ejemplo n.º 1
0
/*
 * Return true when the left and right set are equivalent.
 * Note:  This currently is not implemented.
 */
bool
Escher_SetEquality( Escher_ObjectSet_s * const left_set,
                    Escher_ObjectSet_s * const right_set )
{
  bool rc = false;
  if ( (left_set->head == 0) && (right_set->head == 0) ) {
    rc = true;
  } else if ( ( (left_set->head != 0) && (right_set->head != 0) ) &&
    (Escher_SetCardinality( left_set ) == Escher_SetCardinality( right_set )) ) {
    rc = true;
  } else { /* nop */ }
  return rc;
}
Ejemplo n.º 2
0
static void
Tracking_Display_CB_act5( Tracking_Display * self, const Escher_xtUMLEvent_t * const event )
{
  Escher_ObjectSet_s lapMarkers_space={0}; Escher_ObjectSet_s * lapMarkers = &lapMarkers_space;
  /* SELECT many lapMarkers FROM INSTANCES OF LapMarker */
  XTUML_OAL_STMT_TRACE( 1, "SELECT many lapMarkers FROM INSTANCES OF LapMarker" );
  Escher_CopySet( lapMarkers, &pG_Tracking_LapMarker_extent.active );
  /* UI::setData(unit:laps, value:cardinality lapMarkers) */
  XTUML_OAL_STMT_TRACE( 1, "UI::setData(unit:laps, value:cardinality lapMarkers)" );
  Tracking_UI_setData( GPSWatch_Unit_laps_e, Escher_SetCardinality( lapMarkers ) );
  Escher_ClearSet( lapMarkers );
}
/*
 * class operation:  solve
 */
void
sudoku_SEQUENCE_op_solve( void )
{
  i_t i;Escher_ObjectSet_s sequences_space; Escher_ObjectSet_s * sequences = &sequences_space; /* sequences (SEQUENCE) */
  Escher_InitSet( sequences );
  /* ASSIGN i = 0 */
  i = 0;
  /* SELECT many sequences FROM INSTANCES OF SEQUENCE */
  Escher_CopySet( sequences, &pG_sudoku_SEQUENCE_extent.active );
  /* WHILE ( ( 25 > i ) ) */
  while ( ( 25 > i ) ) {
    i_t j;sudoku_SEQUENCE * sequence;
    /* ASSIGN j = 0 */
    j = 0;
    /* WHILE ( ( 25 > j ) ) */
    while ( ( 25 > j ) ) {
      Escher_ObjectSet_s eligibles_space; Escher_ObjectSet_s * eligibles = &eligibles_space; /* eligibles (ELIGIBLE) */i_t count1;i_t count2;sudoku_SEQUENCE * sequence;
      Escher_InitSet( eligibles );
      /* ::display(  ) */
      sudoku_display();
      /* SELECT many eligibles FROM INSTANCES OF ELIGIBLE */
      Escher_CopySet( eligibles, &pG_sudoku_ELIGIBLE_extent.active );
      /* ASSIGN count1 = cardinality eligibles */
      count1 = Escher_SetCardinality( eligibles );
      /* ASSIGN count2 = 0 */
      count2 = 0;
      /* FOR EACH sequence IN sequences */
      { Escher_Iterator_s iter29;
  sudoku_SEQUENCE * sudoku_SEQUENCEiter29;
  Escher_IteratorReset( &iter29, sequences );
  while ( (sudoku_SEQUENCEiter29 = (sudoku_SEQUENCE *)Escher_IteratorNext( &iter29 )) != 0 ) {
    sequence = sudoku_SEQUENCEiter29; {
        i_t k;
        /* ASSIGN k = sequence.solve_by_pruning() */
        k = sudoku_SEQUENCE_op_solve_by_pruning(sequence);
        }}
}
      /* SELECT many eligibles FROM INSTANCES OF ELIGIBLE */
      Escher_CopySet( eligibles, &pG_sudoku_ELIGIBLE_extent.active );
      /* ASSIGN count2 = cardinality eligibles */
      count2 = Escher_SetCardinality( eligibles );
      /* IF ( ( ( 81 == CELL::score() ) or ( count1 == count2 ) ) ) */
      if ( ( ( 81 == sudoku_CELL_op_score() ) || ( count1 == count2 ) ) ) {
        /* BREAK */
        break;
      }
      /* ASSIGN j = ( j + 1 ) */
      j = ( j + 1 );
      Escher_ClearSet( eligibles );
    }
    /* FOR EACH sequence IN sequences */
    { Escher_Iterator_s iter28;
  sudoku_SEQUENCE * sudoku_SEQUENCEiter28;
  Escher_IteratorReset( &iter28, sequences );
  while ( (sudoku_SEQUENCEiter28 = (sudoku_SEQUENCE *)Escher_IteratorNext( &iter28 )) != 0 ) {
    sequence = sudoku_SEQUENCEiter28; {
      i_t k;
      /* ASSIGN k = sequence.solve_by_elimination() */
      k = sudoku_SEQUENCE_op_solve_by_elimination(sequence);
      }}
}
    /* IF ( ( 81 == CELL::score() ) ) */
    if ( ( 81 == sudoku_CELL_op_score() ) ) {
      /* BREAK */
      break;
    }
    /* ASSIGN i = ( i + 1 ) */
    i = ( i + 1 );
  }
  Escher_ClearSet( sequences );

}