コード例 #1
0
ファイル: Dd.c プロジェクト: zero14777/My-Stuff
int main ()
{
	DictHndl testHash;
	ListHndl testLookUp;

	testHash = NewDictionary (10);

	InsertKey (testHash, "cat", 123);

	InsertKey (testHash, "dog", 234);

	InsertKey (testHash, "fog", 2345);

	InsertKey (testHash, "fog", 245);

	testLookUp = LookUp (testHash, "fog");

	MoveFirst (testLookUp);
	while (!OffEnd (testLookUp))
	{
		int temp = *(int*) GetCurrent (testLookUp);
		printf ("%d ", temp);
		MoveNext (testLookUp);
	}

	printf ("\n");

	if (IsIn (testHash, "dog"))
	{
		printf ("dog is in the table\n");
	}

	DeleteKey (testHash, "cat");

	DeleteKey (testHash, "dog");

	if (IsIn (testHash, "dog"))
	{
		printf ("dog is still in the table\n");
	}

	testLookUp = LookUp (testHash, "dog");

	FreeDictionary (testHash);

	return (0);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: LukasPukenis/Boggle
int main() {
	LoadDictionary("dictionary.txt");
	
	const char * test1results[] = { "ait", "qat", "dae", "quiz", "zed", "zax", "zit", "zea", "aue", "eau", "eat", "adz", "tuque", "ita", "quat", "qua", "uta", "tui", "tix", "tai", "tae", "taxi", "tau", "tax", "tad", "daut", "daze", "zati", "aitu", "adze", "quai", "quad", "quit", "taed" };
	const int test1count = 34;
	const int test1score = 35;
	Results results1 = FindWords("dzxeaiqut", 3, 3);
	checkEquals(results1, test1results, test1count, test1score, "test1");
	FreeWords(results1);

	const char * test2results[] = { "ply", "flir", "eik", "oye", "yuk", "wye", "reik", "wey", "rei", "plue", "ewt", "euk", "ire", "rew", "rue", "tye", "kir", "top", "toph", "lure", "ruly", "toy", "ure", "puer", "tyer", "lie", "yup", "pot", "yew", "fly", "uey", "puli", "upo", "lye", "ilk", "opt", "plu", "lur", "eyot", "kue", "poh", "phot", "pho", "pye", "flukier", "puy", "pul", "hot", "pur", "jot", "joy", "hop", "hoy", "flu", "weir", "oyer", "weil", "plie", "typo", "yeuk", "iure", "pyot", "puir", "pulk", "puly", "pure", "puri", "lire", "lier", "lieu", "erupt", "kilp", "kier", "kuri", "toyer", "glue", "flue", "twyer", "plier", "plyer", "pulik", "gluer", "gluey", "glyph", "fluyt", "fluey", "flier", "flyer", "yukier", "pulier", "gluier", "fluier" };
	const int test2count = 92;
	const int test2score = 117;
	Results results2 = FindWords("qwertyuioplkjhgf", 4, 4);
	checkEquals(results2, test2results, test2count, test2score, "test2");
	FreeWords(results2);

	const char * test3results[] = { "lou", "mol", "cert", "wex", "holk", "rew", "jupon", "mon", "upon", "rec", "rev", "crew", "poh", "rex", "vex", "hom", "mop", "mou", "til", "noh", "nom", "jol", "only", "kit", "lit", "once", "pol", "noup", "pom", "oup", "lop", "ilk", "upo", "hop", "hon", "holy", "wert", "moly", "reck", "trew", "oncer", "vert", "verb", "brew", "moup", "klik", "polk", "poly", "loup", "treck", "ponce" };
	const int test3count = 51;
	const int test3score = 55;
	Results results3 = FindWords("qwertzxcvbmnjklpolkiujhyt", 5, 5);
	checkEquals(results3, test3results, test3count, test3score, "test3");
	FreeWords(results3);

	const char * test4results[] = { "dad", "add", "dada" };
	const int test4count = 3;
	const int test4score = 3;
	Results results4 = FindWords("dadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadadada", 10, 10);
	checkEquals(results4, test4results, test4count, test4score, "test4");
	FreeWords(results4);

	const char * test5results[] = { "not", "bos", "oon", "bone", "tote", "noo", "non", "nebs", "nos", "bosket", "tete", "nek", "tee", "oot", "nonettos", "keb", "ono", "kons", "tot", "bon", "oos", "sot", "ons", "ten", "snoeks", "tet", "ketones", "oke", "sooks", "ton", "bot", "sen", "books", "too", "tene", "otto", "een", "kon", "note", "ene", "obe", "set", "sneb", "boo", "eek", "bet", "toot", "bee", "ben", "tone", "teen", "toetoe", "obo", "bootee", "sob", "one", "skeet", "ket", "tes", "tokens", "toe", "bes", "skeen", "nene", "eon", "ken", "nob", "net", "knees", "nee", "onos", "neb", "betook", "ens", "bonnet", "bete", "son", "neon", "obs", "oes", "bonks", "ose", "see", "nott", "besee", "noon", "nook", "oons", "ketone", "oont", "toes", "tent", "toon", "tons", "beento", "nenes", "kens", "eons", "took", "ebon", "boose", "eten", "book", "boot", "knot", "boon", "bott", "been", "nonbook", "beet", "bene", "koto", "bent", "bonk", "onto", "keto", "seen", "kete", "ones", "keet", "botone", "toko", "toke", "none", "nett", "nete", "tonk", "sone", "teek", "snot", "snob", "sook", "etens", "soot", "neks", "soon", "nobs", "noes", "okes", "nose", "oose", "tose", "beset", "boos", "tenons", "knee", "keen", "sket", "kebs", "besot", "keno", "kent", "knob", "toetoes", "obos", "tees", "ebook", "tens", "sett", "sekt", "sent", "snee", "seek", "sene", "tenon", "skee", "sken", "skeo", "notebook", "esne", "bosk", "bees", "bens", "obes", "enes", "noons", "nooks", "ottos", "tenet", "tenno", "tenne", "toons", "botte", "bonne", "beton", "benet", "benne", "bento", "boons", "tokes", "token", "nonet", "obento", "neons", "snook", "noose", "nones", "tonne", "tonks", "beknot", "teens", "tones", "snoot", "snoke", "snoek", "soote", "nonette", "notes", "bones", "totes", "onset", "boson", "kotos", "keeno", "kenos", "kente", "netes", "teene", "tense", "tetes", "ebons", "sonne", "seton", "sente", "tenes", "betes", "benes", "obese", "nektons", "neese", "betokens", "nebek", "knobs", "tennos", "tennes", "betons", "entetee", "bennet", "bonnes", "bennes", "ketose", "tonnes", "snooks", "snokes", "sootes", "bookoo", "bottes", "ketene", "keenos", "kennet", "nekton", "tenson", "entete", "settee", "sonnes", "setons", "sennet", "sonnet", "beseen", "nebeks", "botonee", "boneset", "betoken", "nonetto", "tonette", "bookoos", "bootees", "kennett", "ketenes", "nonbooks", "botonnee", "nonettes", "tonettes", "nonobese" };
	const int test5count = 274;
	const int test5score = 559;
	Results results5 = FindWords("notebooknotenotesnotnotebooknotenotesnotnotebooknotenotesnotnotebooknotenotesnotnotebooknotenotesnotnotebooknotenotesnotnotebooknotenotesnotnotebooknotenotesnot", 8, 20);
	checkEquals(results5, test5results, test5count, test5score, "test5");
	FreeWords(results5);

	FreeDictionary();

	std::cout << "Done!" << std::endl;

	return 0;
}
コード例 #3
0
ファイル: Dictionarydr.c プロジェクト: zero14777/My-Stuff
int main ()
{
	DictHndl testDict;
	ListHndl testLookUp;

	testDict = NewDictionary (10);

	InsertKey (testDict, "cat", 123);

	InsertKey (testDict, "dog", 234);

	InsertKey (testDict, "fog", 2345);

	InsertKey (testDict, "fog", 245);

	testLookUp = LookUp (testDict, "cat");

	printf ("%d\n" , *(int*) GetFirst (testLookUp));

	PrintKeyLocations (testDict, "fog");

	if (IsIn (testDict, "dog"))
	{
		printf ("dog is in the table\n");
	}

	DeleteKey (testDict, "cat");

	DeleteKey (testDict, "dog");

	if (IsIn (testDict, "dog"))
	{
		printf ("dog is still in the table\n");
	}

	FreeDictionary (testDict);

	return (0);
}
コード例 #4
0
ファイル: LS.c プロジェクト: zero14777/My-Stuff
int main ( int argc, char* argv [])
{
	int i, j;
	DictHndl library;
	int numBooks;
	int dictSize;
	int parser;
	int parseSave;
	int numSearches;
	FILE *libraryBooks;
	FILE *searchBooks;
	char buffer[1000];

	if (argc != 3)
	{
		fprintf (stderr, "usage: %s filename filename\n", argv[0]);
		return 1;
	}

	libraryBooks = fopen( argv[1], "r");
	searchBooks = fopen ( argv[2], "r");

	if (libraryBooks == 0 || searchBooks == 0)
	{
		fprintf (stderr, "File does not exist\n");
		return 1;
	}

	fgets (buffer, 1000, libraryBooks);

	parser = 0;
	while (buffer[parser] >= '0' && buffer[parser] <= '9')
	{
		parser++;
	}

	parseSave = parser;
	parser--;
	numBooks = 0;

	for (j = 1; parser >= 0; j = j * 10)
	{
		numBooks += (buffer[parser] - '0') * j;
		parser--;
	}

	parser = parseSave + 1;

	while (buffer[parser] >= '0' && buffer[parser] <= '9')
	{
		parser++;
	}

	dictSize = 0;
	for (j = 1; parser > parseSave; j = j * 10)
	{
		dictSize += (buffer[parser] - '0') * j;
		parser--;
	}

	library = NewDictionary (dictSize);

	for (i = 0; i < numBooks; i++)
	{
		int reparser = 0;
		int tempLocation = 0;
		parser = 0;
		fgets (buffer, 1000, libraryBooks);

		while (buffer[parser] != ',')
		{
			if (parser == 999)
			{
				fprintf (stderr, "Improper Library Data File\n");
				return 1;
			}
			parser++;
		}

		parseSave = parser;
		parser--;

		for (j = 1; parser >= 0; j = j * 10)
		{
			tempLocation += (buffer[parser] - '0') * j;
			parser--;
		}

		parser = parseSave;
		parser += 2;

		while (buffer[parser] != '\n' && 
			buffer[parser] != EOF && 
			buffer[parser] != '\0')
		{
			buffer[reparser] = buffer[parser];
			parser++;
			reparser++;
		}

		buffer[reparser] = '\0';
		InsertKey (library, buffer, tempLocation);
	}

	fgets (buffer, 1000, searchBooks);
	parser = 0;
	while (buffer[parser] >= '0' && buffer[parser] <= '9')
	{
		parser++;
	}

	parser--;
	numSearches = 0;
	for (j = 1; parser >= 0; j = j * 10)
	{
		numSearches += (buffer[parser] - '0') * j;
		parser--;
	}

	for (i = 0; i < numSearches; i++)
	{
		fgets (buffer, 1000, searchBooks);
		j = 0;
		while (buffer[j] != '\n' &&
			buffer[j] != '\0' &&
			buffer[j] != EOF)
		{
			j++;
		}
		buffer[j] = '\0';
		PrintKeyLocations (library, buffer);
	}

	FreeDictionary (library);
	fclose (libraryBooks);
	fclose (searchBooks);

	return 0;
}
コード例 #5
0
 //Teardown
 ~EnchantBrokerRequestDictionary_TestFixture()
 {
     FreeDictionary(_dict);
 }
コード例 #6
0
 //Teardown
 ~EnchantBrokerFreeDictNoDisposeTestFixture(){
     FreeDictionary(_dictionary);
 }
コード例 #7
0
 //Teardown
 ~EnchantBrokerFreeDictTestFixture()
 {
     FreeDictionary(_dictionary);
 }