mirror of
				https://gitlab.com/klmp200/LO41.git
				synced 2025-10-31 09:13:06 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			52 lines
		
	
	
		
			773 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			773 B
		
	
	
	
		
			C
		
	
	
	
	
	
| //
 | |
| // Created by Antoine Bartuccio on 22/05/2018.
 | |
| //
 | |
| #include "List.h"
 | |
| 
 | |
| GETTER(List, Element*, head)
 | |
| GETTER(List, Element*, tail)
 | |
| GETTER(List, int, size)
 | |
| 
 | |
| void $_free__List(THIS(List)){
 | |
| 	this->clear(this);
 | |
| 	free(this);
 | |
| }
 | |
| 
 | |
| void clear_List(THIS(List)){
 | |
| 	Element * el = this->head;
 | |
| 	Element * el_tmp;
 | |
| 	while (el != NULL){
 | |
| 		el->list = NULL;
 | |
| 		el_tmp = el;
 | |
| 		el = el_tmp->next;
 | |
| 		DELETE(el_tmp);
 | |
| 	}
 | |
| 	this->size = 0;
 | |
| }
 | |
| 
 | |
| void remove_head_List(THIS(List)){
 | |
| 	DELETE(this->head);
 | |
| }
 | |
| 
 | |
| void remove_tail_List(THIS(List)){
 | |
| 	DELETE(this->tail);
 | |
| }
 | |
| 
 | |
| List *$_init_List(){
 | |
| 	List *l = (List*) malloc_or_die(sizeof(List));
 | |
| 	l->size = 0;
 | |
| 	l->head = NULL;
 | |
| 	l->tail = NULL;
 | |
| 
 | |
| 	LINK_ALL(List, l,
 | |
| 			 get_head,
 | |
| 			 get_tail,
 | |
| 			 get_size,
 | |
| 			 clear,
 | |
| 			 remove_head,
 | |
| 			 remove_tail
 | |
| 	)
 | |
| 	return l;
 | |
| }
 | |
| 
 |