Example #1
0
File: LL.c Project: forstezt/CS252
int main() {
	
	LinkedList* ll = llCreate();

	char* str = "hello";
	char* str2 = "ping";
	char* str3 = "pong";
	char* str4 = "pinga";
	char* str5 = "da";
	char* str6 = "ponga";
	char* str7 = "yup";

	llAdd(&ll, str);
	llAdd(&ll, str);
	llAdd(&ll, str);
	llAdd(&ll, str4);
	llAdd(&ll, str);
	llAdd(&ll, str6);	

	printf("LinkedList after adding a bunch of strings:\n");
	llDisplay(ll);
	printf("Size:  %d\n\n", size(ll));


	int index = 4;
	printf("LinkedList after adding '%d' at index %d:\n", str7, index);
	addAtIndex(&ll, str7, index);
	llDisplay(ll);
	printf("Size:  %d\n\n", size(ll));

	
	index = 3;
	printf("LinkedList after removing the word at index %d:\n", index);
	removeAtIndex(&ll, index);
	llDisplay(ll);
	printf("Size:  %d\n\n", size(ll));

	printf("LinkedList after removing all instances of %d:\n", str);
	removeString(&ll, str);
	llDisplay(ll);
	printf("Size:  %d\n\n", size(ll));
	
	llAdd(&ll, str);
	llAdd(&ll, str);
	llAdd(&ll, str);
	llAdd(&ll, str4);
	llAdd(&ll, str);
	llAdd(&ll, str6);
	
	printf("LinkedList after repopulation:\n");
	llDisplay(ll);

	llDelete(&ll);
	
	printf("Size:  %d\n", size(ll));
}
Example #2
0
File: LL.c Project: forstezt/CS252
void llDelete(LinkedList** ll) {

	while(*ll != NULL) {
		removeAtIndex(ll, 0);
		llDisplay(*ll);
	}
	
}
Example #3
0
int main() {
  
  LinkedList* ll = llCreate();
  llDisplay(ll);
  
  char* s = (char*)malloc(6*sizeof(char));
  s[0] = 'h';
  s[1] = 'e';
  s[2] = 'l';
  s[3] = 'l';
  s[4] = 'o';
  s[5] = '\0';

  llAdd(&ll, s);
  //  llAdd(ll, 5);
  //  llAdd(ll, 7);
  llDisplay(ll);
}