X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsn-count-cuts.c;h=f5a810ca22c0f394739ad9385fede7c3128f4d86;hb=5786c25e07292aa4b9df65f44c8be532d429767d;hp=d6e13f9b17337b321cd67b6b9a25b755b149df4a;hpb=b60344a5a9aa2f2c7bbc215ae171823ecf83c9d8;p=sort-networks.git diff --git a/src/sn-count-cuts.c b/src/sn-count-cuts.c index d6e13f9..f5a810c 100644 --- a/src/sn-count-cuts.c +++ b/src/sn-count-cuts.c @@ -37,6 +37,8 @@ static int cuts_num = 0; static uint64_t iterations_num = 1000000; static char *input_file = NULL; +static _Bool exit_after_collision = 0; + static sn_hashtable_t *hashtable; static double possible_cuts (int inputs_num) /* {{{ */ @@ -63,6 +65,7 @@ static void exit_usage (void) /* {{{ */ printf ("sn-count-cuts [options] \n" "\n" "Options:\n" + " -1 Exit after the first collision has been detected.\n" " -c Number of cuts to perform.\n" " -n Maximum number of cuts to perform.\n" " -h Display this help and exit.\n" @@ -74,10 +77,14 @@ static int read_options (int argc, char **argv) /* {{{ */ { int option; - while ((option = getopt (argc, argv, "c:n:h")) != -1) + while ((option = getopt (argc, argv, "1c:n:h")) != -1) { switch (option) { + case '1': + exit_after_collision = 1; + break; + case 'c': { int tmp = atoi (optarg); @@ -200,6 +207,10 @@ int main (int argc, char **argv) /* {{{ */ { create_random_cut (n); + if (exit_after_collision) + if (sn_hashtable_get_collisions (hashtable) > 0) + break; + if ((i < 100) || ((i < 1000) && (((i + 1) % 10) == 0)) || ((i < 10000) && (((i + 1) % 100) == 0))