#include "StringUtil.h"

Data Structures | |
| struct | WordList |
Functions | |
| WordList * | newWordList (nat length, string *words) |
| void | deleteWordList (WordList *this) |
| void | printWordList (WordList *this) |
| string | readFile (string fileName) |
| boolean | isAlpha (char c) |
| WordList * | words (string str) |
| boolean | contains (string *words, nat length, string w) |
| void | nub (WordList *this) |
| void | wordListToLower (WordList *this) |
| void | sortWith (WordList *this, boolean le(string, string)) |
| string | findRhyme (WordList *this, string w) |
| boolean contains | ( | string * | words, | |
| nat | length, | |||
| string | w | |||
| ) |
Check, whether a string is contained within an array of strings.
| words | is an array containing strings | |
| length | is the number of elements contained in the array. | |
| w | is the string we are looking for in the array. |
| void deleteWordList | ( | WordList * | this | ) |
A destructor function for WordList-objects.
This functions frees every word stored within the list and furthermore the array, wich contained the strings. Finally it frees the WordList-object itself.
| this | is the word list to be deleted. |
| string findRhyme | ( | WordList * | this, | |
| string | w | |||
| ) |
For a given word this function tries to find a rhyme word within a word list. The passed word list is assumed to be sorted such that rhyming words can be found next to each other.
| this | a word list where rhyming words are searched within. The list is assumed to be sorted by a rhyming relation. | |
| w | The word we try to find a rhyme word for. |
| boolean isAlpha | ( | char | c | ) |
This function test, if the given argument is a letter of the roman alphabet or a German umlaut or the German s-z-ligature letter. For the German non-Ascii letters the latin-1 encoding is assumed.
| c | is the character which is tested to be an alphabetic character. |
| WordList* newWordList | ( | nat | length, | |
| string * | words | |||
| ) |
A constructor function for WordList-objects.
| length | The length of the newly created list. | |
| words | The allready initialized array with the words. |
| void nub | ( | WordList * | this | ) |
A procedure for deleting duplicates from the word list.
Internally copies of the strings are being made. The old array and the the old strings get deleted!
A new length is calculated and a new array allocated.
| this | is the word list which gets modified. |
| void printWordList | ( | WordList * | this | ) |
A simple print procedure, which prints every word contained in the word list to standard out: Every word gets printed on a single line.
| this | is the word list to be printed. |
| string readFile | ( | string | fileName | ) |
This function reads in a text file from the filesystem and gives the contents of the file as a single large string in the memory.
| fileName | the name of the file to be read. |
| void sortWith | ( | WordList * | this, | |
| boolean | lestring, string | |||
| ) |
This procedure sorts the internal array of the word list by a given function for the less equal comparision. It uses bubble sort as internal sorting algorithm.
| this | the word list to be sorted. | |
| le | A function which test for to strings if the first one is smaller or equal to the second one in a certain relation. |
| void wordListToLower | ( | WordList * | this | ) |
This procedure modifies everery single string stored in the word list into a corresponding string of lower case letters. No new memory is allocated. Nothing gets deleted.
| this | is the word list which gets modified. |
| WordList* words | ( | string | str | ) |
Creates a new WordList-object from a string by splitting the string into words. The string is splitted whenever a charcter has been found, which is not a letter of the Roman alphabet.
| A | complete text, which is to be splitted into single words. |
1.5.5