-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash_node.h
More file actions
73 lines (61 loc) · 1.65 KB
/
hash_node.h
File metadata and controls
73 lines (61 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef HASH_NODE_H
#define HASH_NODE_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct hash_node {
int key;
int hash_code;
char* full_name;
char* address;
char* city;
char* state;
char* zip;
struct hash_node* prev;
struct hash_node* next;
} hash_node_t;
/**
* Creates a new hash node
* @return Pointer to the newly created hash node, or NULL if allocation failed
*/
hash_node_t* hn_create();
/**
* Destroys a hash node and frees all associated memory
* @param node Pointer to the hash node to destroy
* @return Always returns NULL
*/
hash_node_t* hn_destroy(hash_node_t* node);
/**
* Checks if a node is the head of a linked list
* @param node The node to check
* @return true if the node is a head (no previous node), false otherwise
*/
bool hn_is_head(hash_node_t* node);
/**
* Checks if a node is the tail of a linked list
* @param node The node to check
* @return true if the node is a tail (no next node), false otherwise
*/
bool hn_is_tail(hash_node_t* node);
/**
* Inserts a new node after the specified node
* @param node The node after which to insert
* @param new_node The node to insert
*/
void hn_insert_after(hash_node_t* node, hash_node_t* new_node);
/**
* Inserts a new node before the specified node
* @param node The node before which to insert
* @param new_node The node to insert
*/
void hn_insert_before(hash_node_t* node, hash_node_t* new_node);
/**
* Removes a node from its linked list without freeing it
* @param node The node to remove
*/
void hn_remove(hash_node_t* node);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HASH_NODE_H */