| 1 |
#ifndef AWS_COMMON_LINKED_LIST_H |
| 2 |
#define AWS_COMMON_LINKED_LIST_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/common/common.h> |
| 10 |
|
| 11 |
#include <stddef.h> |
| 12 |
|
| 13 |
AWS_PUSH_SANE_WARNING_LEVEL |
| 14 |
|
| 15 |
struct aws_linked_list_node { |
| 16 |
struct aws_linked_list_node *next; |
| 17 |
struct aws_linked_list_node *prev; |
| 18 |
}; |
| 19 |
|
| 20 |
struct aws_linked_list { |
| 21 |
struct aws_linked_list_node head; |
| 22 |
struct aws_linked_list_node tail; |
| 23 |
}; |
| 24 |
|
| 25 |
AWS_EXTERN_C_BEGIN |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
AWS_STATIC_IMPL void aws_linked_list_node_reset(struct aws_linked_list_node *node); |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
AWS_STATIC_IMPL bool aws_linked_list_empty(const struct aws_linked_list *list); |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
AWS_STATIC_IMPL bool aws_linked_list_is_valid(const struct aws_linked_list *list); |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
AWS_STATIC_IMPL bool aws_linked_list_node_next_is_valid(const struct aws_linked_list_node *node); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
AWS_STATIC_IMPL bool aws_linked_list_node_prev_is_valid(const struct aws_linked_list_node *node); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
AWS_STATIC_IMPL bool aws_linked_list_is_valid_deep(const struct aws_linked_list *list); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
AWS_STATIC_IMPL void aws_linked_list_init(struct aws_linked_list *list); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_begin(const struct aws_linked_list *list); |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_end(const struct aws_linked_list *list); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_rbegin(const struct aws_linked_list *list); |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_rend(const struct aws_linked_list *list); |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_next(const struct aws_linked_list_node *node); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_prev(const struct aws_linked_list_node *node); |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
AWS_STATIC_IMPL void aws_linked_list_insert_after( |
| 115 |
struct aws_linked_list_node *after, |
| 116 |
struct aws_linked_list_node *to_add); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
AWS_STATIC_IMPL void aws_linked_list_swap_nodes(struct aws_linked_list_node *a, struct aws_linked_list_node *b); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
AWS_STATIC_IMPL void aws_linked_list_insert_before( |
| 126 |
struct aws_linked_list_node *before, |
| 127 |
struct aws_linked_list_node *to_add); |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
AWS_STATIC_IMPL void aws_linked_list_remove(struct aws_linked_list_node *node); |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
AWS_STATIC_IMPL void aws_linked_list_push_back(struct aws_linked_list *list, struct aws_linked_list_node *node); |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_back(const struct aws_linked_list *list); |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_back(struct aws_linked_list *list); |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
AWS_STATIC_IMPL void aws_linked_list_push_front(struct aws_linked_list *list, struct aws_linked_list_node *node); |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_front(const struct aws_linked_list *list); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_front(struct aws_linked_list *list); |
| 162 |
|
| 163 |
AWS_STATIC_IMPL void aws_linked_list_swap_contents( |
| 164 |
struct aws_linked_list *AWS_RESTRICT a, |
| 165 |
struct aws_linked_list *AWS_RESTRICT b); |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
AWS_STATIC_IMPL void aws_linked_list_move_all_back( |
| 173 |
struct aws_linked_list *AWS_RESTRICT dst, |
| 174 |
struct aws_linked_list *AWS_RESTRICT src); |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
AWS_STATIC_IMPL void aws_linked_list_move_all_front( |
| 182 |
struct aws_linked_list *AWS_RESTRICT dst, |
| 183 |
struct aws_linked_list *AWS_RESTRICT src); |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
AWS_STATIC_IMPL bool aws_linked_list_node_is_in_list(struct aws_linked_list_node *node); |
| 189 |
AWS_EXTERN_C_END |
| 190 |
|
| 191 |
#ifndef AWS_NO_STATIC_IMPL |
| 192 |
# include <aws/common/linked_list.inl> |
| 193 |
#endif |
| 194 |
AWS_POP_SANE_WARNING_LEVEL |
| 195 |
|
| 196 |
#endif |