Graph Convolutional Branch and Bound v1.0.0
A TSP solver that combines a graph convolutional network with a 1-Tree branch-and-bound.
Loading...
Searching...
No Matches
list_iterator.c
Go to the documentation of this file.
1
15#include "list_functions.h"
16
17
19 if (!list)
20 return NULL;
21
22 ListIterator *new_iterator = malloc(sizeof(ListIterator));
23 new_iterator->list = list;
24 new_iterator->curr = new_iterator->list->head;
25 new_iterator->index = 0;
26 return new_iterator;
27}
28
29
31 return (iterator && iterator->curr && iterator->curr->value) ? iterator->curr->value : NULL;
32}
33
34
36 return (iterator) ? iterator->index < get_list_size(iterator->list) : 0;
37}
38
39
41 if (is_list_iterator_valid(iterator)) {
42 iterator->index++;
43
44 if (is_list_iterator_valid(iterator)) {
45 iterator->curr = iterator->curr->next;
46 }
47 }
48}
49
50
52 free(iterator);
53}
54
55
57 if (!is_list_iterator_valid(iterator)) {
58 return NULL;
59 }
60
61 void *element = get_current_list_iterator_element(iterator);
62 list_iterator_next(iterator);
63 return element;
64}
size_t get_list_size(List *list)
Gets the size of the List.
The declaration of the functions to manipulate the List.
void list_iterator_next(ListIterator *iterator)
Used to move the ListIterator to the next value of the object.
Definition: list_iterator.c:40
void * get_current_list_iterator_element(ListIterator *iterator)
Method used to get the current DllElem of an ListIterator.
Definition: list_iterator.c:30
void * list_iterator_get_next(ListIterator *iterator)
Method that retrieves the current DllElem of an ListIterator and moves the pointer to the next object...
Definition: list_iterator.c:56
bool is_list_iterator_valid(ListIterator *iterator)
Used to check if the ListIterator is valid.
Definition: list_iterator.c:35
ListIterator * create_list_iterator(List *list)
Used for the creation of a new ListIterator.
Definition: list_iterator.c:18
void delete_list_iterator(ListIterator *iterator)
Delete the ListIterator given.
Definition: list_iterator.c:51
void * value
The value of the element, void pointer to be able to store any type of data.
Definition: linked_list.h:28
struct DllElem * next
The next element in the List.
Definition: linked_list.h:29
The iterator for the List.
Definition: linked_list.h:43
DllElem * curr
The current DllElem (element) of the List.
Definition: linked_list.h:45
List * list
The List to iterate.
Definition: linked_list.h:44
size_t index
The current index of the element in the List.
Definition: linked_list.h:46
The double linked list.
Definition: linked_list.h:35
DllElem * head
The head of the list as a DllElem.
Definition: linked_list.h:36