projects
/
sort-networks.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b60344a
)
sn-count-cuts: Implement the "-1" (exit after collision) option.
author
Florian Forster
<octo@leeloo.octo.it>
Mon, 17 Jan 2011 13:30:00 +0000
(14:30 +0100)
committer
Florian Forster
<octo@leeloo.octo.it>
Mon, 17 Jan 2011 13:30:00 +0000
(14:30 +0100)
src/sn-count-cuts.c
patch
|
blob
|
history
diff --git
a/src/sn-count-cuts.c
b/src/sn-count-cuts.c
index
d6e13f9
..
f5a810c
100644
(file)
--- 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 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) /* {{{ */
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] <file0> <file1>\n"
"\n"
"Options:\n"
printf ("sn-count-cuts [options] <file0> <file1>\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"
" -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;
{
int option;
- while ((option = getopt (argc, argv, "c:n:h")) != -1)
+ while ((option = getopt (argc, argv, "
1
c:n:h")) != -1)
{
switch (option)
{
{
switch (option)
{
+ case '1':
+ exit_after_collision = 1;
+ break;
+
case 'c':
{
int tmp = atoi (optarg);
case 'c':
{
int tmp = atoi (optarg);
@@
-200,6
+207,10
@@
int main (int argc, char **argv) /* {{{ */
{
create_random_cut (n);
{
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))
if ((i < 100)
|| ((i < 1000) && (((i + 1) % 10) == 0))
|| ((i < 10000) && (((i + 1) % 100) == 0))