diff --git a/dd/d19/circular__doubly__linked__list_8c.html b/dd/d19/circular__doubly__linked__list_8c.html
new file mode 100644
index 00000000..e0b08edf
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c.html
@@ -0,0 +1,735 @@
+
+
+
+
+
+
+
+
Algorithms_in_C: data_structures/linked_list/circular_doubly_linked_list.c File Reference
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Algorithms_in_C 1.0.0
+
+ Set of algorithms implemented in C.
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+
+
+
+
#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+ |
+typedef struct node | ListNode |
+ | to verify assumptions made by the program and print a diagnostic message if this assumption is false.
|
+ |
+
+
+
Circular Doubly Linked List combines the properties of a doubly linked list and a circular linked list in which two consecutive elements are linked or connected by the previous. Next, the pointer and the last node point to the first node via the next pointer, and the first node points to the last node via the previous pointer.
+
In this implementation, functions to insert at the head, insert at the last index, delete the first node, delete the last node, display list, and get list size functions are coded.
+
- Author
- Sahil Kandhare
+
+
+
◆ ListNode
+
+
+
+
+
to verify assumptions made by the program and print a diagnostic message if this assumption is false.
+
to provide a set of integer types with universally consistent definitions that are operating system-independent for IO operations for including functions involving memory allocation such as malloc
+
Circular Doubly linked list struct
+
+
+
+
+
+
◆ create_node()
+
+
+
+
+
+ ListNode * create_node |
+ ( |
+ uint64_t |
+ data | ) |
+ |
+
+
+
+
+
Create a list node.
+
- Parameters
-
+
+ data | the data that the node initialises with |
+
+
+
+
- Returns
- ListNode* pointer to the newly created list node
+
40{
+
+
+
43 new_list->
next = new_list;
+
44 new_list->prev = new_list;
+
45 return new_list;
+
46}
+
#define malloc(bytes)
This macro replace the standard malloc function with malloc_dbg.
Definition: malloc_dbg.h:18
+
Definition: prime_factoriziation.c:25
+
Node, the basic data structure in the tree.
Definition: binary_search_tree.c:15
+
struct node * next
List pointers.
Definition: bfs.c:24
+
uint64_t value
Data stored on each node.
Definition: circular_doubly_linked_list.c:31
+
+
+
+
+
◆ delete_from_head()
+
+
+
+
+
Function for deletion of the first node in list.
+
- Parameters
-
+
+ head | start pointer of list |
+
+
+
+
- Returns
- ListNode* pointer to the list node after deleting first node
+
112{
+
113 if (head == NULL)
+
114 {
+
115 printf("The list is empty\n");
+
116 return head;
+
117 }
+
+
119 temp1 = head;
+
120 temp2 = temp1->prev;
+
121 if (temp1 == temp2)
+
122 {
+
+
124 head = NULL;
+
125 return head;
+
126 }
+
+
128 (temp1->
next)->prev = temp2;
+
+
+
131 return head;
+
132}
+
#define free(ptr)
This macro replace the standard free function with free_dbg.
Definition: malloc_dbg.h:26
+
+
+
+
+
◆ delete_from_tail()
+
+
+
+
+
Function for deletion of the last node in list.
+
- Parameters
-
+
+ head | start pointer of list |
+
+
+
+
- Returns
- ListNode* pointer to the list node after deleting first node
+
141{
+
142 if (head == NULL)
+
143 {
+
144 printf("The list is empty\n");
+
145 return head;
+
146 }
+
147
+
+
149 temp1 = head;
+
150 temp2 = temp1->prev;
+
151 if (temp1 == temp2)
+
152 {
+
+
154 head = NULL;
+
155 return head;
+
156 }
+
157 (temp2->prev)->
next = temp1;
+
158 temp1->prev = temp2->prev;
+
+
160 return head;
+
161}
+
int next(Vector *vec)
This function gets the next item from the Vector each time it's called.
Definition: vector.c:102
+
+
+
+
+
+
+
◆ display_list()
+
+
+
+
+
+ void display_list |
+ ( |
+ ListNode * |
+ head | ) |
+ |
+
+
+
+
+
Display list function.
+
- Parameters
-
+
+ head | start pointer of list |
+
+
+
+
- Returns
- void
+
192{
+
193 printf("\nContents of your linked list: ");
+
+
195 temp = head;
+
196 if (head != NULL)
+
197 {
+
198 while (temp->
next != head)
+
199 {
+
200 printf(
"%" PRIu64
" <-> ", temp->
value);
+
+
202 }
+
203 if (temp->
next == head)
+
204 {
+
205 printf(
"%" PRIu64, temp->
value);
+
206 }
+
207 }
+
208 else
+
209 {
+
210 printf("The list is empty");
+
211 }
+
212 printf("\n");
+
213}
+
+
+
+
+
◆ get()
+
+
+
+
+
+ uint64_t get |
+ ( |
+ ListNode * |
+ list, |
+
+
+ |
+ |
+ const int |
+ index |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
access the list by index
+
- Parameters
-
+
+ list | pointer to the target list |
+ index | access location |
+
+
+
+
- Returns
- the value at the specified index, wrapping around if the index is larger than the size of the target list
+
224{
+
225 if (
list == NULL || index < 0)
+
226 {
+
227 exit(EXIT_FAILURE);
+
228 }
+
+
230 for (int i = 0; i < index; ++i)
+
231 {
+
+
233 }
+
+
235}
+
Doubly linked list struct.
Definition: doubly_linked_list.c:24
+
+
+
+
+
◆ getsize()
+
+
+
+
+
+ int getsize |
+ ( |
+ ListNode * |
+ head | ) |
+ |
+
+
+
+
+
The function that will return current size of list.
+
- Parameters
-
+
+ head | start pointer of list |
+
+
+
+
- Returns
- int size of list
+
170{
+
171 if (!head)
+
172 {
+
173 return 0;
+
174 }
+
175 int size = 1;
+
+
177 while (temp != head)
+
178 {
+
+
180 size++;
+
181 }
+
182 return size;
+
183}
+
+
+
+
+
◆ insert_at_head()
+
+
+
+
+
+ ListNode * insert_at_head |
+ ( |
+ ListNode * |
+ head, |
+
+
+ |
+ |
+ uint64_t |
+ data |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
Insert a node at start of list.
+
- Parameters
-
+
+ head | start pointer of list |
+ data | the data that the node initialises with |
+
+
+
+
- Returns
- ListNode* pointer to the newly created list node inserted at the head
+
56{
+
57 if (head == NULL)
+
58 {
+
+
60 return head;
+
61 }
+
62 else
+
63 {
+
+
+
66 temp = head->prev;
+
67 new_node->
next = head;
+
68 head->prev = new_node;
+
69 new_node->prev = temp;
+
70 temp->
next = new_node;
+
71 head = new_node;
+
72 return head;
+
73 }
+
74}
+
ListNode * create_node(uint64_t data)
Create a list node.
Definition: circular_doubly_linked_list.c:39
+
+
+
+
+
+
+
◆ insert_at_tail()
+
+
+
+
+
+ ListNode * insert_at_tail |
+ ( |
+ ListNode * |
+ head, |
+
+
+ |
+ |
+ uint64_t |
+ data |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
Insert a node at end of list.
+
- Parameters
-
+
+ head | start pointer of list |
+ data | the data that the node initialises with |
+
+
+
+
- Returns
- ListNode* pointer to the newly added list node that was inserted at the head of list.
+
85{
+
86 if (head == NULL)
+
87 {
+
+
89 return head;
+
90 }
+
91 else
+
92 {
+
+
+
95 temp1 = head;
+
96 temp2 = head->prev;
+
97 new_node->prev = temp2;
+
98 new_node->
next = temp1;
+
99 temp1->prev = new_node;
+
100 temp2->
next = new_node;
+
101 return head;
+
102 }
+
103}
+
+
+
+
+
+
+
◆ main()
+
+
+
+
+
+ int main |
+ ( |
+ void |
+ | ) |
+ |
+
+
+
+
+
Main function.
+
- Returns
- 0 on exit
+
301{
+
+
303 return 0;
+
304}
+
static void test()
Self-test implementations.
Definition: circular_doubly_linked_list.c:241
+
+
+
+
+
+
+
◆ test()
+
+
+
+
+
+
+
+
+ static void test |
+ ( |
+ void |
+ | ) |
+ |
+
+
+ |
+
+static |
+
+
+
+
+
Self-test implementations.
+
- Returns
- void
+
242{
+
+
244 unsigned int array[] = {2, 3, 4, 5, 6};
+
245
+
246 assert(
getsize(testList) == 0);
+
247
+
248 printf("Testing inserting elements:\n");
+
249 for (int i = 0; i < 5; ++i)
+
250 {
+
+
+
253 assert(testList->
value == array[i]);
+
254 assert(
getsize(testList) == i + 1);
+
255 }
+
256
+
257 printf("\nTesting removing elements:\n");
+
258 for (int i = 4; i > -1; --i)
+
259 {
+
+
261 assert(testList->
value == array[i]);
+
+
263 assert(
getsize(testList) == i);
+
264 }
+
265
+
266 printf("\nTesting inserting at tail:\n");
+
267 for (int i = 0; i < 5; ++i)
+
268 {
+
+
+
271 assert(
get(testList, i) == array[i]);
+
272 assert(
getsize(testList) == i + 1);
+
273 }
+
274
+
275 printf("\nTesting removing from tail:\n");
+
276 for (int i = 4; i > -1; --i)
+
277 {
+
+
+
280 assert(
getsize(testList) == i);
+
281
+
282
+
283 if (testList != NULL)
+
284 {
+
285 assert(
get(testList, i) == testList->
value);
+
286 }
+
287 else
+
288 {
+
289
+
290
+
291 assert(i == 0);
+
292 }
+
293 }
+
294}
+
ListNode * delete_from_head(ListNode *head)
Function for deletion of the first node in list.
Definition: circular_doubly_linked_list.c:111
+
void display_list(ListNode *head)
Display list function.
Definition: circular_doubly_linked_list.c:191
+
int getsize(ListNode *head)
The function that will return current size of list.
Definition: circular_doubly_linked_list.c:169
+
ListNode * insert_at_head(ListNode *head, uint64_t data)
Insert a node at start of list.
Definition: circular_doubly_linked_list.c:55
+
ListNode * delete_from_tail(ListNode *head)
Function for deletion of the last node in list.
Definition: circular_doubly_linked_list.c:140
+
uint64_t get(ListNode *list, const int index)
access the list by index
Definition: circular_doubly_linked_list.c:223
+
ListNode * insert_at_tail(ListNode *head, uint64_t data)
Insert a node at end of list.
Definition: circular_doubly_linked_list.c:84
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dd/d19/circular__doubly__linked__list_8c.js b/dd/d19/circular__doubly__linked__list_8c.js
new file mode 100644
index 00000000..77a68279
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c.js
@@ -0,0 +1,15 @@
+var circular__doubly__linked__list_8c =
+[
+ [ "node", "d5/da1/structnode.html", "d5/da1/structnode" ],
+ [ "ListNode", "dd/d19/circular__doubly__linked__list_8c.html#a77bc93c58c46925ba49f51f2d1a32899", null ],
+ [ "create_node", "dd/d19/circular__doubly__linked__list_8c.html#a4a89f96b090dfdb505b714195e59ca5b", null ],
+ [ "delete_from_head", "dd/d19/circular__doubly__linked__list_8c.html#a1418cac5ddf9edb58fca97afce27b456", null ],
+ [ "delete_from_tail", "dd/d19/circular__doubly__linked__list_8c.html#abf4cdda9fbace9822612349d19ec2e72", null ],
+ [ "display_list", "dd/d19/circular__doubly__linked__list_8c.html#a5411df421a94177700868b34887d5d0e", null ],
+ [ "get", "dd/d19/circular__doubly__linked__list_8c.html#ac53a0550fa74838246bc783ddc005ec1", null ],
+ [ "getsize", "dd/d19/circular__doubly__linked__list_8c.html#a6a64eb6265e703639bbfec9c3db93e0c", null ],
+ [ "insert_at_head", "dd/d19/circular__doubly__linked__list_8c.html#a964882e633c25a29b12237e29f20fa9a", null ],
+ [ "insert_at_tail", "dd/d19/circular__doubly__linked__list_8c.html#aee328f691615862c4298fe730d66027b", null ],
+ [ "main", "dd/d19/circular__doubly__linked__list_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ],
+ [ "test", "dd/d19/circular__doubly__linked__list_8c.html#aa8dca7b867074164d5f45b0f3851269d", null ]
+];
\ No newline at end of file
diff --git a/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.map b/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.map
new file mode 100644
index 00000000..846434c3
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.map
@@ -0,0 +1,4 @@
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.md5 b/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.md5
new file mode 100644
index 00000000..e6721b55
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.md5
@@ -0,0 +1 @@
+4edb8a4e6028f29d0ef9e371aad8d4cf
\ No newline at end of file
diff --git a/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.svg b/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.svg
new file mode 100644
index 00000000..76a79757
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_a964882e633c25a29b12237e29f20fa9a_cgraph.svg
@@ -0,0 +1,36 @@
+
+
+
+
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map
new file mode 100644
index 00000000..eadcc477
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map
@@ -0,0 +1,12 @@
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5
new file mode 100644
index 00000000..758368c1
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5
@@ -0,0 +1 @@
+f99109205761a9e060cfef95fa342607
\ No newline at end of file
diff --git a/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg
new file mode 100644
index 00000000..1c4f47d5
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg
@@ -0,0 +1,162 @@
+
+
+
+
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.map b/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.map
new file mode 100644
index 00000000..29da3d18
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.map
@@ -0,0 +1,4 @@
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.md5 b/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.md5
new file mode 100644
index 00000000..01d86c84
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.md5
@@ -0,0 +1 @@
+5ac123540760418957099ee4ac1a302e
\ No newline at end of file
diff --git a/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.svg b/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.svg
new file mode 100644
index 00000000..04cc1a6e
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_abf4cdda9fbace9822612349d19ec2e72_cgraph.svg
@@ -0,0 +1,36 @@
+
+
+
+
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map
new file mode 100644
index 00000000..fcd8d73f
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map
@@ -0,0 +1,13 @@
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5
new file mode 100644
index 00000000..f86b0196
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5
@@ -0,0 +1 @@
+b5a6ce5f5a303d5caf937d1882c63ae7
\ No newline at end of file
diff --git a/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg
new file mode 100644
index 00000000..91dd89d8
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg
@@ -0,0 +1,177 @@
+
+
+
+
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.map b/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.map
new file mode 100644
index 00000000..bd23a788
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.map
@@ -0,0 +1,4 @@
+
diff --git a/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.md5 b/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.md5
new file mode 100644
index 00000000..73df452f
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.md5
@@ -0,0 +1 @@
+13d8348ac8ca227eb80c51d606493f00
\ No newline at end of file
diff --git a/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.svg b/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.svg
new file mode 100644
index 00000000..3c801baf
--- /dev/null
+++ b/dd/d19/circular__doubly__linked__list_8c_aee328f691615862c4298fe730d66027b_cgraph.svg
@@ -0,0 +1,36 @@
+
+
+
+
+
diff --git a/dd/d29/doubly__linked__list_8c.html b/dd/d29/doubly__linked__list_8c.html
index 3e8c3108..97ccac9c 100644
--- a/dd/d29/doubly__linked__list_8c.html
+++ b/dd/d29/doubly__linked__list_8c.html
@@ -286,7 +286,7 @@ Functions
232 }
233}
-
struct node * next
pointer to the node
Definition: bfs.c:24
+
struct node * next
List pointers.
Definition: bfs.c:24
diff --git a/dd/d75/structqueue__coll__graph.map b/dd/d75/structqueue__coll__graph.map
index ccb328c8..97a83451 100644
--- a/dd/d75/structqueue__coll__graph.map
+++ b/dd/d75/structqueue__coll__graph.map
@@ -1,4 +1,4 @@