35b8555ff457cb83b559327c6d7e9a1c5e5d5b04 tdreszer Tue Mar 15 09:31:17 2011 -0700 Added useful function used by text search alogrithm diff --git src/lib/common.c src/lib/common.c index fdff84b..d3796a1 100644 --- src/lib/common.c +++ src/lib/common.c @@ -739,30 +739,42 @@ e = strchr(s, delimiter); if (e == NULL) el = slNameNew(s); else { el = slNameNewN(s, e-s); e += 1; } slAddHead(&list, el); s = e; } slReverse(&list); return list; } +struct slName *slNameListOfUniqueWords(char *text) +// Return list of unique words found by parsing string delimited by whitespace. +{ +struct slName *list = NULL; +char *word = NULL; +while ((word = nextWord(&text)) != NULL) + slNameStore(&list, word); + +slReverse(&list); +return list; +} + struct slName *slNameListFromStringArray(char *stringArray[], int arraySize) /* Return list of slNames from an array of strings of length arraySize. * If a string in the array is NULL, the array will be treated as * NULL-terminated (shorter than arraySize). */ { char *s; struct slName *list = NULL, *el; int i; if (stringArray == NULL) return NULL; for (i = 0; i < arraySize; i++) { s = stringArray[i]; if (s == NULL) break;