diff options
author | Paul Duncan <pabs@pablotron.org> | 2019-02-03 21:12:11 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2019-02-03 21:12:11 -0500 |
commit | 0f544be878f72b09d516a64c60e3cbd66f7cfd81 (patch) | |
tree | adb9868e1b45494f83abac8420107864b009e271 /km-init-type.c | |
parent | 33a722132491ebdd31722f0cada0f81f6b082282 (diff) | |
download | kmeans-0f544be878f72b09d516a64c60e3cbd66f7cfd81.tar.bz2 kmeans-0f544be878f72b09d516a64c60e3cbd66f7cfd81.zip |
add km_init(), refactor existing init
Diffstat (limited to 'km-init-type.c')
-rw-r--r-- | km-init-type.c | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/km-init-type.c b/km-init-type.c deleted file mode 100644 index 27fc1ee..0000000 --- a/km-init-type.c +++ /dev/null @@ -1,32 +0,0 @@ -#include <stddef.h> // size_t -#include <string.h> // strcmp() -#include "km.h" - -static const struct { - const km_init_type_t type; - const char * const name; -} TYPES[] = {{ - .name = "rand", - .type = KM_INIT_TYPE_RAND, -}, { - .name = "forgy", - .type = KM_INIT_TYPE_FORGY, -}}; - -#define NUM_TYPES (sizeof(TYPES) / sizeof(TYPES[0])) - -km_init_type_t -km_get_init_type( - const char * const s -) { - // find init method - for (size_t i = 0; i < NUM_TYPES; i++) { - if (!strcmp(s, TYPES[i].name)) { - // return type - return TYPES[i].type; - } - } - - // return failure - return KM_INIT_TYPE_LAST; -} |