Exemple #1
0
StashFileSystem::StashFileSystem(QObject *parent) :
    QObject(parent),
    root(DirectoryNode)
{
    root.children = new StashNode();
    displayRoot();
}
Exemple #2
0
 void main() {
	char menu[LINES][STR_SIZE] = {"Add",
								  "Delete",
								  "search",
								  "Display All",
								  "Display Root",
								  "Exit"};
	char key;
	int current = 0, i = 0, item, preItem;
	BSTNode *tree = NULL;

	do {
		clrscr();
		for (i = 0; i < LINES; i++) {
			if (current == i) {
				textcolor(CYAN + BLINK);
				cprintf("\r%s\n", menu[i]);
			} else {
				textcolor(WHITE);
				cprintf("\r%s\n", menu[i]);
			}
		}

		key = getch();
		if (!key)
			key = getch();
		switch (key) {
			case UP:
				current = (current + LINES - 1) % LINES;
				break;
			case DOWN:
				current = ++current % LINES;
				break;
			case END:
				current = LINES - 1;
				break;
			case HOME:
				current = 0;
				break;
			case ENTER:
				clrscr();
				textcolor(WHITE);
				switch (current)
				{
					case 0:
						printf("Please enter an integer to add: ");
						scanf("%d", &item);
						insertNode(&tree, item);
						break;
					case 1:
						printf("Please give me node to delete: ");
						scanf("%d", &item);
						removeNode(tree, item);
						break;
					case 2:
						printf("Please enter an integer to search for: ");
						scanf("%d", &item);
						if (findNode(tree, item))
							printf("Found!\n");
						else
							printf("Not Found!\n");
						break;
					case 3:
						displayTree(tree);
						break;
					case 4:
						displayRoot(tree);
						break;
					case 5:
						printf("GOOD BYE");
						break;
				}

				getch();
				break;
		}
   }
   while (current != (LINES - 1) || key != ENTER);

}