Esempio n. 1
0
Trie *
createTrie(void) {
	Trie * trie = newTrie();
	int i = 0;
	while( commands[i].name != NULL ) {
		addCommand(trie, commands[i].name, commands[i].com);
		i++;
	}
	return trie;
}	
Esempio n. 2
0
void init() {
//	printf("%d \n", sizeof(Trie3));
	initDocumentDescriptorPool();
	initLinkedListDefaultPool();
	lazy_list = newLinkedList();
	queries = newLinkedList();
//	int numCPU = sysconf(_SC_NPROCESSORS_ONLN);
//	ht = new_Hash_Table();
	//THREAD_ENABLE=1;
	trie = newTrie();
//	int i = 0;
	eltire = newTrie3();
//	dtrie = newTrie();
//	docList = newLinkedList();
}
Esempio n. 3
0
int
addCommand( Trie * trie, const char * commandName, int (* command)(void *) ) {
	if ( (*commandName) == '\0' ) {
		trie->command = command;
		return 0;
	}
	char c = tolower(*commandName);
	if ( c < 'a' || c > 'z' ) {
		perror("Invalid command name");
		return -1;
	}
	if ( (trie->array)[c-'a'] == NULL ) {
		if ( ( (trie->array)[c-'a'] = newTrie() ) == NULL ) {
			return -1;
		}
	}
	++commandName;
	return addCommand((trie->array)[c-'a'], commandName, command);
}