Esempio n. 1
0
/** remove_if
  *
  * Removes all nodes whose data when passed into the predicate function returns true
  *
  * @param llist a pointer to the list
  * @param pred_func a pointer to a function that when it returns true it will remove the element from the list and do nothing otherwise @see list_pred.
  * @param free_func a pointer to a function that is responsible for freeing the node's data
  * @return the number of nodes that were removed.
  */
int remove_if(list* llist, list_pred pred_func, list_op free_func)
{
    int number_nodes_removed = 0;
    if (!is_empty(llist)) {
	node* current = llist->head;
	while (current != NULL) {
	    if (pred_func(current->data)) {
		if (current->prev == NULL) {
		    current = current->next;
		    remove_front(llist, free_func);
		} else if (current->next == NULL) {
		    current = current->next;
		    remove_back(llist, free_func);
		} else {
		    free_func(current->data);
		    node* to_free = current;
		    current->prev->next = current->next;
		    current->next->prev = current->prev;
		    current = current->next;
		    free(to_free);
		    llist->size -= 1;
		}
		number_nodes_removed += 1;
	    } else {
		current = current->next;
	    }
	}
    }
    return number_nodes_removed;
}
Esempio n. 2
0
/** remove_index
  *
  * Removes the indexth node of the linked list
  *
  * @warning Note the data the node is pointing to is also freed. If you have any pointers to this node's data it will be freed!
  *
  * @param llist a pointer to the list.
  * @param index index of the node to remove.
  * @param free_func pointer to a function that is responsible for freeing the node's data.
  * @return -1 if the remove failed 0 if the remove succeeded.
  */
int remove_index(list* llist, int index, list_op free_func)
{
	int i;
	if(llist->size<index){	
		return -1;
	}
	else if(index==0){
		return remove_front(llist,free_func);
	}
	else{
		if(index==llist->size)remove_back(llist,free_func);
		else{
			node* remNode=llist->head;
			for(i=0;i<index;i++){
				remNode=remNode->next;
			}
			free_func(remNode->data);
			remNode->prev->next=remNode->next;
			remNode->next->prev=remNode->prev;
			free(remNode);
			llist->size--;
		}
	}
	return 0;
    /// @todo Implement
    /// @note Remember to also free the node itself
    /// @note free_func is a function that is responsible for freeing the node's data only.
}
Esempio n. 3
0
/** remove_if
  *
  * Removes all nodes whose data when passed into the predicate function returns true
  *
  * @param llist a pointer to the list
  * @param pred_func a pointer to a function that when it returns true it will remove the element from the list and do nothing otherwise @see list_pred.
  * @param free_func a pointer to a function that is responsible for freeing the node's data
  * @return the number of nodes that were removed.
  */
int remove_if(list* llist, list_pred pred_func, list_op free_func)
{
   int num = llist->size;
   int count = 0;

   node* nd = llist->head;

   while(num--)
   {
      if(pred_func(nd->data))
      {
         //Store next node
         node* temp = nd->next;
         
         //Remove node from list
         if(nd == llist->head)
         {
            remove_front(llist, free_func);
         }
         else if(nd == llist->tail)
         {
            remove_back(llist, free_func);
         }
         else
         {
            //Node is neither front nor back
            nd->prev->next = nd->next;
            nd->next->prev = nd->prev;
            
            free_func(nd->data);
            free(nd);
            
            llist->size--;
         }

         count++;
         
         nd = temp;
      }
      else
      {
         nd = nd->next;
      }
   }

   return count;
}
Esempio n. 4
0
/** remove_if
  *
  * Removes all nodes whose data when passed into the predicate function returns true
  *
  * @param llist a pointer to the list
  * @param pred_func a pointer to a function that when it returns true it will remove the element from the list and do nothing otherwise @see list_pred.
  * @param free_func a pointer to a function that is responsible for freeing the node's data
  * @return the number of nodes that were removed.
  */
int remove_if(list* llist, list_pred pred_func, list_op free_func)
{
    /// @todo Implement changing the return value!
    /// @note remember to also free all nodes you remove.
    /// @note be sure to call pred_func on the NODES DATA to check if the node needs to be removed.
    /// @note free_func is a function that is responsible for freeing the node's data only.
    int num = 0;
    if (is_empty(llist)) {
      return 0;
    }
    // iterate through the list 
    node *current = llist->head;
    while (current != NULL) {
      node *prevNode = current->prev;
      node *nextNode = current->next;
      if (pred_func(current->data)) { // if pred_func returns true
        num++; // increment the number of removed nodes
        if (current == llist->head) { // if the node to be removed is in the front
          remove_front(llist, free_func);
        } else if (current == llist->tail) { // if the node to be removed is in the back
          remove_back(llist, free_func);
        } else { // if the node to be removed is in the middle
          // free the data of the current node
          free_func(current->data);
          // free the current node
          free(current);
          // redirect the prev and next pointers of the previous node and the next node
          nextNode->prev = prevNode;
          prevNode->next = nextNode;
          // decrement the size of the list
          llist->size--;
        }
      }
      // move to the next node for all cases
      current = nextNode;
    }
    return num;
}
Esempio n. 5
0
int main(void) {
  llist* list = create_list();
  lnode* new_node;
  lnode* found_node;
  point* p = create_point(0, 0);
  list->head = NULL;

  /* test case 1 - what does an empty list contain? */
  printf("TEST CASE 1\n");
  traverse(list, print_point_node);
  printf("\n");

  /* test case 2 - what happens when you add a node to the
     front of an empty list? */
  printf("TEST CASE 2\n");
  new_node = create_node(create_point(2,5));
  add_front(list, new_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 3 - what happens when you add a node to the front
     of a list with one node? */
  printf("TEST CASE 3\n");
  new_node = create_node(create_point(3,7));
  add_front(list, new_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 4 - what happens when you add a node to the front
     of a list with more than one node? */
  printf("TEST CASE 4\n");
  new_node = create_node(create_point(1,4));
  add_front(list, new_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 5 - what happens when you remove a node from the front
     of a list with more than one node? */
  printf("TEST CASE 5\n");
  remove_front(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 6 - what happens when you remove a node from the front
     of a list with one node? */
  printf("TEST CASE 6\n");
  remove_front(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 7 - what happens when you remove a node from the front
     of an empty list? */
  printf("TEST CASE 7\n");
  remove_front(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 8 - what happens when you add a node to the
     back of an empty list? */
  printf("TEST CASE 8\n");
  new_node = create_node(create_point(2,5));
  add_back(list, new_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 9 - what happens when you add a node to the back
     of a list with one node? */
  printf("TEST CASE 9\n");
  new_node = create_node(create_point(3,7));
  add_back(list, new_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 10 - what happens when you add a node to the back
     of a list with more than one node? */
  printf("TEST CASE 10\n");
  new_node = create_node(create_point(1,4));
  add_back(list, new_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 11 - what happens when you remove a node from the back
     of a list with more than one node? */
  printf("TEST CASE 11\n");
  remove_back(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 12 - what happens when you remove a node from the back
     of a list with one node? */
  printf("TEST CASE 12\n");
  remove_back(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 13 - what happens when you remove a node from the back
     of an empty list? */
  printf("TEST CASE 13\n");
  remove_back(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 14 - what happens when you try to find an occurrence
     of a given data point in an empty list? */
  printf("TEST CASE 14\n");
  p->x = 3;
  p->y = 7;
  found_node = find_occurrence(list, p, compare_point_data);
  print_point_node(found_node);
  printf("\n");

  /* test case 15 - what happens when you try to find an occurrence
     of a given data point in a list of that one node? */
  printf("TEST CASE 15\n");
  p->x = 3;
  p->y = 7;
  new_node = create_node(create_point(3, 7));
  add_front(list, new_node);
  found_node = find_occurrence(list, p, compare_point_data);
  print_point_node(found_node);
  printf("\n");
  
  /* test case 16 - what happens when you try to find an occurrence
     of a given data point in a list of one different node? */
  printf("TEST CASE 16\n");
  p->x = 5;
  p->y = 14;
  found_node = find_occurrence(list, p, compare_point_data);
  print_point_node(found_node);
  printf("\n");

  /* test case 17 - what happens when you try to find an occurrence
     of a given data point in a list of lots of nodes (one matching)?
     NOTE: if your list contains multiple nodes with matching data,
     returning any of them is fine.
  */
  printf("TEST CASE 17\n");
  new_node = create_node(create_point(5,2));
  add_front(list, new_node);
  new_node = create_node(create_point(6,30));
  add_back(list, new_node);
  new_node = create_node(create_point(1,1));
  add_front(list, new_node);
  p->x = 3;
  p->y = 7;
  found_node = find_occurrence(list, p, compare_point_data);
  print_point_node(found_node);
  printf("\n");

  /* test case 18 - what happens when you try to find an occurrence
     of a given data point in a list of lots of nodes (none matching)? */
  printf("TEST CASE 18\n");
  p->x = 5;
  p->y = 14;
  found_node = find_occurrence(list, p, compare_point_data);
  print_point_node(found_node);
  printf("\n");

  /* test case 19 - what happens when you try to free a list
     of lots of nodes? YOU WILL HAVE TO RUN VALGRIND TO MAKE
     SURE YOU GET NO ERRORS HERE. Memory leaks are otherwise
     invisible!
  */
  printf("TEST CASE 19\n");
  free_list(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 20 - what happens when you try to free a list
     of one node? YOU WILL HAVE TO RUN VALGRIND TO MAKE
     SURE YOU GET NO ERRORS HERE. 
  */
  printf("TEST CASE 20\n");
  new_node = create_node(create_point(7,14));
  add_front(list, new_node);
  free_list(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");

  /* test case 21 - what happens when you try to free an empty list?
     YOU WILL HAVE TO RUN VALGRIND TO MAKE SURE YOU GET NO ERRORS HERE.
  */
  printf("TEST CASE 21\n");
  free_list(list, free_point_node);
  traverse(list, print_point_node);
  printf("\n");
  

	free(p);
  free(list);
  return 0;
}
Esempio n. 6
0
/* This main function does a little testing
   Like all good CS Majors you should test
   your code here. There is no substitute for testing
   and you should be sure to test for all edge cases
   e.g., calling remove_front on an empty list.
*/
int main(void)
{
	/* Now to make use of all of this stuff */
	list* llist = create_list();

  /* What does an empty list contain?  Lets use our handy traversal function */
  printf("TEST CASE 1\nAn Empty list should print nothing here:\n");
  traverse(llist, print_person);
	printf("\n");

 	/* Lets add a person from front and then print */
 	push_front(llist, create_person("Andrew", 24));
 	printf("TEST CASE 2\nA List with one person should print that person:\n");
 	traverse(llist, print_person);
 	printf("\n");

  
  /* Lets remove two persons from front and then print */
  remove_front(llist, free_person); // remove a list with more than 1 elements
 	remove_front(llist, free_person); // remove a list with only 1 element
 	printf("TEST CASE 3\nAnother Empty list should print nothing here:\n");
 	traverse(llist, print_person);
 	printf("\n");

 	/* Lets add two people and then print */
 	push_front(llist, create_person("Nick", 22));
 	push_front(llist, create_person("Randal", 21));
 	printf("TEST CASE 4\nA List with two people should print those two people:\n");
 	traverse(llist, print_person);
 	printf("\n");

	/* Lets copy this list */
	list* llist2 = copy_list(llist, copy_person);
	printf("TEST CASE 5\nA copied list should print out the same two people:\n");
 	traverse(llist2, print_person);
 	printf("\n");

  /* Lets kill the list */
  empty_list(llist, free_person);
 	printf("TEST CASE 6\nAfter freeing all nodes the list should be empty:\n");
 	traverse(llist, print_person);
	printf("\n");

	/* Let's make a list of people, and remove certain ones! */
	/* Should remove anyone whose name is 8+ characters long */
	push_front(llist, create_person("Josephine", 27));
	push_front(llist, create_person("Dave", 34));
	push_front(llist, create_person("Benjamin", 23));
	push_front(llist, create_person("Lisa", 41));
	push_front(llist, create_person("Maximilian", 24));
	remove_if(llist, long_name, free_person);
	printf("TEST CASE 7\nShould only print 2 people with short names:\n");
	traverse(llist, print_person);
  printf("\n");
  
  /* Testing over clean up*/
  empty_list(llist, free_person);
  free(llist);
  empty_list(llist2, free_person);
  free(llist2);


  // MY TESTS!!!

  // Test case 8 -- create_list(); is_empty() and size() when the list is empty
  list* myList = create_list();
  printf("TEST CASE 8\nShould print 1 and then 0:\n");
  printf("%d\t", is_empty(myList));
  printf("%d\n", size(myList));
  printf("\n");

  // Test case 9 -- front() and back() when the list is empty
  printf("TEST CASE 9\nShould print nothing:\n");
  print_person(front(myList));
  print_person(back(myList));
  printf("\n");

  // Test case 10 -- push_front() and push_back() and traverse()
  push_front(myList, create_person("Dan", 24));
  push_back(myList, create_person("Sun", 24));
  push_front(myList, create_person("Someone", 100));
  push_back(myList, create_person("Somebody", 1));
  printf("TEST CASE 10\nShould print 4 people in the order of Someone-Dan-Sun-Somebody:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 11 -- size() and is_empty() when the list is not empty
  printf("TEST CASE 11\nShould return 0 and then 4:\n");
  printf("%d\t", is_empty(myList));
  printf("%d\n", size(myList));
  printf("\n");

  // Test case 12 -- front() and back() when the list is not empty
  printf("TEST CASE 12\nShould print Someone then Somebody:\n");
  print_person(front(myList));
  print_person(back(myList));
  printf("\n");

  // Test case 13 -- copy_list()
  list* myListCopy = copy_list(myList, copy_person);
  printf("TEST CASE 13\nA copied list should print 4 people in the order of Someone-Dan-Sun-Somebody:\n");
  traverse(myListCopy, print_person);
  printf("\n");

  // Test case 14 -- remove_front() and remove_back() when the list is not empty
  remove_front(myList, free_person);
  remove_back(myList, free_person);
  printf("TEST CASE 13\nShould print 2 people in the order of Dan-Sun:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 15 -- remove_if()
  push_front(myList, create_person("LLLLLLLLLLLLL", 1));
  push_front(myList, create_person("MMMMMMMMM", 1));
  push_front(myList, create_person("AAA", 3));
  push_back(myList, create_person("DDD", 5));
  push_back(myList, create_person("T", 10));
  push_back(myList, create_person("VVVVVVVVVV", 1));
  remove_if(myList, long_name, free_person);
  printf("TEST CASE 13\nShould print 5 people:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 16 -- empty_list()
  empty_list(myList, free_person);
  printf("TEST CASE 16\nShould print nothing:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 17 -- remove_front() and remove_back() when the list is empty
  remove_front(myList, free_person);
  remove_back(myList, free_person);
  printf("TEST CASE 17\nNo error should occur: \n");
  printf("\n");

  // Test case 18 -- push big data into the copied list to test push_front() and copy_list()
  for (int i = 0; i < 1000000; i++) {
    push_front(myListCopy, create_person("BIG", 1));
  }
  printf("TEST CASE 18\nShould print 1000004 (add a large number of data): \n");
  printf("%d\n", size(myListCopy));
  printf("\n");

  empty_list(myList, free_person);
  free(myList);

  empty_list(myListCopy, free_person);
  free(myListCopy);

  return 0;
}
Esempio n. 7
0
/* This main function does a little testing
   Like all good CS Majors you should test
   your code here. There is no substitute for testing
   and you should be sure to test for all edge cases
   e.g., calling remove_front on an empty list.
*/
int main(void)
{
	/* Now to make use of all of this stuff */
	list* llist = create_list();

  	/* What does an empty list contain?  Lets use our handy traversal function */
  	printf("TEST CASE 1\nAn Empty list should print nothing here:\n");
  	traverse(llist, print_student);
	printf("\n");

 	/* Lets add a student and then print */
 	push_front(llist, create_student("Mahmoud", "Joudeh", 20));
 	printf("TEST CASE 2\nA List with one student should print that student:\n");
	
	traverse(llist, print_student);
 	printf("\n");

 	/* Lets remove that student and then print */
 	remove_front(llist, free_student);
 	printf("TEST CASE 3\nAnother Empty list should print nothing here:\n");
 	
	traverse(llist, print_student);
 	printf("\n");

 	/* Lets add two elements and then print */
 	push_front(llist, create_student("Alex", "Ikonomidis", 19));
 	push_front(llist, create_student("Andrew", "Kim", 21));
 	printf("TEST CASE 4\nA List with two students should print those two students:\n");
 	traverse(llist, print_student);
 	printf("\n");

	/* Lets copy this list */
	list* llist2 = copy_list(llist, copy_student);
	
	printf("TEST CASE 5\nA copied list should print out the same two students:\n");
 	traverse(llist, print_student);
 	printf("\n");

  	/* Lets kill the list */
  	empty_list(llist, free_student);
 	printf("TEST CASE 6\nAfter freeing all nodes the list should be empty:\n");
 	traverse(llist, print_student);
	printf("\n");
	empty_list(llist2, free_student);
	free(llist);
	free(llist2);
 	/* YOU ARE REQUIRED TO MAKE MORE TEST CASES THAN THE ONES PROVIDED HERE */
 	/* You will get points off if you do not you should at least test each function here */

	/*Sample Tests*/
	llist = create_list();
	printf("\n4 Elements added\n ");
	push_front(llist, create_student("Abra", "Cadabra",14));
	push_front(llist, create_student("bing", "google", 10));
	push_front(llist, create_student("costa", "rica", 10));
	push_front(llist, create_student("Delta", " ", 17));
	//push_front(llist, NULL);
	traverse(llist, print_student);
	printf("\n");
		
	
	printf("Removed %d elements of age 10\n", remove_if(llist, age_is_ten, free_student));
	traverse(llist, print_student);
	remove_front(llist, free_student);
	list* list2 = copy_list(llist, copy_student);
	remove_front(llist, free_student);
	remove_back(list2, free_student);
	printf("\nEmptying list \n");
	traverse(llist, print_student_simple);
	
	i = 0;
	printf("\n500 elements being added\n");
	while(i++ < 500)
	{
			
			push_front(llist, create_student("sdflj", "sdlfs", rand()%10));

	}

	printf("\nis Empty? %d\n", is_empty(llist));
	printf("\n");
	//traverse(llist, print_student);
	
	
	
	i = 0;
	
	printf("\nRemoving 500 elements until empty\n");
	while(!is_empty(llist)){

		remove_front(llist, free_student);
	
		//practice(llist);
	}
	printf("\nis Empty? %d\n", is_empty(llist));
	
	empty_list(llist, free_student);

	remove_if(llist, trueVal, free_student);
	
	traverse(llist, print_student);	
	
	printf("\n");
	printf("\nEmptiness\n");
	remove_back(llist, free_student);
	
	traverse(llist, print_student);
	
	traverse(list2, print_student);
	
	
 	/* Testing over clean up*/
	empty_list(llist, free_student);
	empty_list(list2, free_student);
 	free(llist);
	free(list2);
	
	printf("\nAdding random numbers to the list\n");
	llist = create_list();
	i = 0;
	while (i < sizeof(numeros)/sizeof(numeros[0]))
		push_back(llist, create_student("a", "ab", numeros[i++]));

	traverse(llist, print_student_simple);
	printf("\n");

	printf("\nRemoving numbers in a random order\n");
	i = 0;
	while( i < sizeof(_numeros)/sizeof(_numeros[0]))
	{
		int total = remove_if(llist, randomizer, free_student);
		printf("size is %d after %d removes of %d: ", size(llist),  total, _numeros[i]);
		traverse(llist, print_student_simple);
		printf("\n");
		i++;
	}
	printf("\nEmpty size: \n");
	printf("list of size %d: ", size(llist));traverse(llist, print_student_simple);

	printf("\nTesting push_back and remove_if\n");
	push_back(llist, create_student("a", "b", 9));
	traverse(llist, print_student_simple); printf("\n");
	remove_if(llist, age_is_ten, free_student);
	traverse(llist, print_student_simple); printf("\n");
	empty_list(llist, free_student);
	traverse(llist, print_student_simple); printf("\n");
	printf("\nTesting push_front and remove_if\n");
	push_front(llist, create_student("a", "b", 9));
	traverse(llist, print_student_simple); printf("\n");
	remove_if(llist, age_is_ten, free_student);
	traverse(llist, print_student_simple); printf("\n");
	empty_list(llist, free_student);
	traverse(llist, print_student_simple); printf("\n");
	
	printf("\nTesting push_back and remove_if\n");
	push_back(llist, create_student("a", "b", 10));
	traverse(llist, print_student_simple); printf("\n");
	remove_if(llist, age_is_ten, free_student);
	traverse(llist, print_student_simple); printf("\n");
		
	printf("\nTesting push_front and remove_if\n");
	push_front(llist, create_student("a", "b", 10));
	traverse(llist, print_student_simple); printf("\n");
	remove_if(llist, age_is_ten, free_student);
	traverse(llist, print_student_simple); printf("\n");
	
	
	printf("\nTesting push_back and remove_front\n");
	push_back(llist, create_student("a", "b", 9));
	traverse(llist, print_student_simple); printf("\n");
	remove_front(llist, free_student);
	traverse(llist, print_student_simple); printf("\n");
	
	printf("\nTesting push_back and remove_back\n");
	push_back(llist, create_student("a", "b", 9));
	traverse(llist, print_student_simple); printf("\n");
	remove_back(llist, free_student);
	traverse(llist, print_student_simple); printf("\n");

	printf("\nTesting push_front and remove_front\n");
	push_front(llist, create_student("a", "b", 9));
	traverse(llist, print_student_simple); printf("\n");
	remove_front(llist, free_student);
	traverse(llist, print_student_simple); printf("\n");

	printf("\nTesting push_front and remove_back\n");
	push_front(llist, create_student("a", "b", 9));
	traverse(llist, print_student_simple); printf("\n");
	remove_back(llist, free_student);
	traverse(llist, print_student_simple); printf("\n");
	
	printf("\nEVERYTHING WORKS!!!\n");
	
	i = 0;
	printf("\n Testing return value of remove_if on empty list\n");
	while(i++ < 6)
		printf("%d ",remove_if(llist, trueVal, free_student));

	printf("\n Testing return value of remove_front on empty list\n");
	i = 0;
	while(i++ < 6)
		printf("%d ", remove_front(llist, free_student));

	printf("\n Testing return value of remove_back on empty list\n");
	i = 0;
	while(i++ < 6)
		printf("%d ", remove_back(llist, free_student));

	printf("\n Testing return value of remove_if on filled list\n");
	i = 0;
	while(i++ < 6)
		push_back(llist, create_student("a", "b", 3));
	i = 0;
	while(i++ < 6)
		printf("%d ",remove_if(llist, trueVal, free_student));
	
	printf("\n Testing return value of remove_front on filled list\n");
	i = 0;
	while(i++ < 6)
		push_back(llist, create_student("a", "b", 3));
	i = 0;
	while(i++ < 6)
		printf("%d ",remove_front(llist,free_student));

	printf("\n Testing return value of remove_back on filled list\n");
	i = 0;
	while(i++ < 6)
		push_back(llist, create_student("a", "b", 3));
	i = 0;
	while(i++ < 6)
		printf("%d ",remove_back(llist,free_student));
	
	printf("\nTesting size: ");
	i = 0;
	while(i++ < 6)
		push_back(llist, create_student("a", "b", 3));
	
	printf("\nsize %d: ", size(llist));
	printf("\nEmptying it: ");
	empty_list(llist, free_student);
	printf("\tsize %d: ", size(llist));

	i = 0;
	while(i++ < 6)
		push_back(llist, create_student("a", "b", numeros[i]));
	printf("\nTesting copy method, values getting squared\n");
	printf("\n");
	list2 = copy_list(llist, copy_student0);
	traverse(llist, print_student_simple);
	printf("\n");
	traverse(list2, print_student_simple);
	printf("\n");

	printf("\nTesting front and back methods:\n");
	printf("Front: ");print_student(front(llist));
	printf("\nBack: ");print_student(back(llist));
	printf("\n_Front: ");print_student(front(list2));
	printf("\n_Back: ");print_student(back(list2));

	printf("\nTesting remove_front and remove_back together\n");
	i = 0;
	while (i++ < 6)
	{
		remove_back(llist, free_student);
		printf("\n");
		traverse(llist, print_student_simple);
		remove_front(list2, free_student);
		printf("\n");
		traverse(list2, print_student_simple);
	}

	printf("\nEmptying the list\n");
	while(i++ < 9)
		empty_list(llist, free_student);

	printf("\nAdding a null element\n");
	push_back(llist, NULL);
	traverse(llist, print_student_simple);

	list *list3 = create_list();
	empty_list(list3, free_student_nulls);
	
	print_student_simple(front(list3));
	traverse(list3, print_student_simple);

	empty_list(llist, free_student_nulls);
	empty_list(list2, free_student);
	push_back(llist, create_student("one", "two", 5));
	push_back(list2, create_student("one", "two", 10));
	
	printf("\nTesting front and back methods with one element\n");
	printf("Front: ");print_student_simple(front(llist));
	printf("\nBack: ");print_student_simple(back(llist));
	printf("\n_Front: ");print_student_simple(front(list2));
	printf("\n_Back: ");print_student_simple(back(list2));
	
	empty_list(llist, free_student_nulls);
	empty_list(list2, free_student_nulls);
	printf("\nTesting front and back methods with empty list\n");
	printf("Front: ");print_student_simple(front(llist));
	printf("\nBack: ");print_student_simple(back(llist));
	printf("\n_Front: ");print_student_simple(front(list2));
	printf("\n_Back: ");print_student_simple(back(list2));
	printf("\nAll Empty List : \"");
	traverse(llist, print_student_simple);
	traverse(list2, print_student_simple);
	printf("\"\n");
	empty_list(list3, free_student);
	printf("\nYAY\n");
	free(llist);
	free(list2);
	
	free(list3);
	//cd /mnt/hgfs/B/Current\ Projects/HW\ 11\ \(2110\)/
  	return 0;
}