Skip to content
Snippets Groups Projects
Commit 58bcc9c1 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

naming convention of dfs

parent 5c4d0247
Branches
No related tags found
No related merge requests found
#include "dfs.h" #include "dfs.h"
void enqueue(struct directory *dr, struct list_head *stack) void enqueue(struct directory *dr, struct list_head *list)
{ {
if (list_empty(stack)) if (list_empty(list))
INIT_LIST_HEAD(stack); INIT_LIST_HEAD(list);
list_add(&dr->list, stack); list_add(&dr->list, list);
} }
struct directory *dequeue(struct list_head *stack) struct directory *dequeue(struct list_head *list)
{ {
struct directory *dr; struct directory *dr;
if (list_empty(stack)) if (list_empty(list))
return NULL; return NULL;
dr = list_first_entry(stack, struct directory, list); dr = list_first_entry(list, struct directory, list);
list_del(&dr->list); list_del(&dr->list);
return dr; return dr;
} }
bool search(char *path, struct list_head *visited) bool search(char *path, struct list_head *list)
{ {
struct directory *dr; struct directory *dr;
list_for_each_entry(dr, visited, list) { list_for_each_entry(dr, list, list) {
if (strncmp(dr->path, path, 1024) == 0) if (strncmp(dr->path, path, 1024) == 0)
return true; return true;
} }
......
...@@ -7,9 +7,9 @@ struct directory { ...@@ -7,9 +7,9 @@ struct directory {
char *path; char *path;
}; };
void enqueue(struct directory *n, struct list_head *stack); void enqueue(struct directory *n, struct list_head *list);
struct directory *dequeue(struct list_head *stack); struct directory *dequeue(struct list_head *list);
bool search(char *path, struct list_head *visited); bool search(char *path, struct list_head *list);
void clear_list(struct list_head *visited); void clear_list(struct list_head *list);
void print_list_dfs(struct list_head *collection_of_nodes_and_stuff); void print_list_dfs(struct list_head *list);
#endif #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment