bool HandStrength::operator < (const HandStrength &hs) const
{
    if (get_combination() < hs.get_combination()) {
        return true;
    } else if (get_combination() > hs.get_combination()) {
        return false;
    }
    // combinations are equal, compare cards
    // compare combination cards
    for (size_t i = 0; i < combination_cards.size(); ++i) {
        if (combination_cards[i]->get_face() <
            hs.combination_cards[i]->get_face()) {
            return true;
        } else if (combination_cards[i]->get_face() >
                   hs.combination_cards[i]->get_face()) {
            return false;
        }
    }
    // compare kicker cards
    for (size_t i= 0; i < kicker_cards.size(); ++i) {
        if (kicker_cards[i]->get_face() < hs.kicker_cards[i]->get_face()) {
            return true;
        } else if (kicker_cards[i]->get_face() > hs.kicker_cards[i]->get_face()) {
            return false;
        }
    }

    return false;
}
Exemple #2
0
int
main(int argc, char **argv)
{
  int nuniv;
  int nelem;
  int ncombo, *elems, cnum, i;
  Combinations vp;

  if (argc != 3) {
    printf("usage: %s nuniv nelem\n", argv[0]);
    return 1;
  }
  nuniv = atoi(argv[1]);
  nelem = atoi(argv[2]);
  vp = init_combinations(nuniv, nelem);
  if (vp == NULL) {
    printf("init_combinations failed\n");
    return 1;
  }
  ncombo = num_combinations(vp);
  elems = (int *) malloc(nelem * sizeof(int));
  for (cnum=0; cnum<ncombo; cnum++) {
    get_combination(vp, cnum, elems);
    for (i=0; i<nelem; i++)
      printf("%d ", elems[i] + 1);
    printf("\n");
  }
  free_combinations(vp);
  return 0;
}
bool HandStrength::operator == (const HandStrength &hs) const
{
    if (get_combination() != hs.get_combination()) {
        return false;
    }
    // compare combination cards
    for (unsigned i = 0; i < combination_cards.size(); ++i) {
        if (combination_cards[i]->get_face() != hs.combination_cards[i]->get_face()) {
            return false;
        }
    }
    // compare kicker cards
    for (unsigned i = 0; i < kicker_cards.size(); ++i) {
        if (kicker_cards[i]->get_face() != hs.kicker_cards[i]->get_face()) {
            return false;
        }
    }

    return true;
}