Implementation if a double ended queue data structure for generic pointers.
More...
|
typedef int(* | cmp_fun )(const void *elem, const void *key) |
| The type of the pointer compare function. More...
|
|
typedef struct pdeq | pdeq |
| The pointer double ended queue (list). More...
|
|
|
pdeq * | new_pdeq (void) |
| Creates a new double ended pointer list. More...
|
|
void | del_pdeq (pdeq *dq) |
| Delete a double ended pointer list. More...
|
|
size_t | pdeq_len (pdeq const *dq) |
| Returns the length of a double ended pointer list. More...
|
|
int | pdeq_empty (pdeq const *dq) |
| Checks if a list is empty. More...
|
|
int | pdeq_contains (pdeq const *dq, const void *x) |
| Returns non-zero if a double ended pointer list contains a pointer x. More...
|
|
void * | pdeq_search (pdeq const *qp, cmp_fun cmp, const void *key) |
| Search a key in a double ended pointer list, the search is controlled by a compare function. More...
|
|
void ** | pdeq_copyl (const pdeq *qp, const void **dst) |
| Convert the double ended pointer list into a linear array beginning from left, the first element in the linear array will be the left one. More...
|
|
void ** | pdeq_copyr (const pdeq *qp, const void **dst) |
| Convert the double ended pointer list into a linear array beginning from right, the first element in the linear array will be the right one. More...
|
|
pdeq * | pdeq_putl (pdeq *dq, const void *x) |
| Add a pointer to the left side of a double ended pointer list. More...
|
|
pdeq * | pdeq_putr (pdeq *dq, const void *x) |
| Add a pointer to the right side of a double ended pointer list. More...
|
|
void * | pdeq_getl (pdeq *dq) |
| Retrieve (and remove) a pointer from the left site of a double ended pointer list. More...
|
|
void * | pdeq_getr (pdeq *dq) |
| Retrieve (and remove) a pointer from the right site of a double ended pointer list. More...
|
|
Implementation if a double ended queue data structure for generic pointers.
typedef int(* cmp_fun)(const void *elem, const void *key) |
The type of the pointer compare function.
- Parameters
-
elem | The list element. |
key | The user supplied key. |
- Returns
- 0 if the element matches the key, non-zero else.
Definition at line 33 of file pdeq.h.
The pointer double ended queue (list).
Definition at line 38 of file pdeq.h.
void del_pdeq |
( |
pdeq * |
dq | ) |
|
Delete a double ended pointer list.
- Parameters
-
dq | The list to be deleted. |
Creates a new double ended pointer list.
- Returns
- A new list.
int pdeq_contains |
( |
pdeq const * |
dq, |
|
|
const void * |
x |
|
) |
| |
Returns non-zero if a double ended pointer list contains a pointer x.
- Parameters
-
dq | The list. |
x | The pointer to be searched for. |
void** pdeq_copyl |
( |
const pdeq * |
qp, |
|
|
const void ** |
dst |
|
) |
| |
Convert the double ended pointer list into a linear array beginning from left, the first element in the linear array will be the left one.
- Parameters
-
qp | The list. |
dst | A pointer to a pointer array with must be at least pdeq_len(dq) * sizeof(void *) |
- Returns
- dst
void** pdeq_copyr |
( |
const pdeq * |
qp, |
|
|
const void ** |
dst |
|
) |
| |
Convert the double ended pointer list into a linear array beginning from right, the first element in the linear array will be the right one.
- Parameters
-
qp | The list. |
dst | A pointer to a pointer array with must be at least pdeq_len(dq) * sizeof(void *) |
- Returns
- dst
int pdeq_empty |
( |
pdeq const * |
dq | ) |
|
Checks if a list is empty.
- Parameters
-
- Returns
- non-zero if the list is empty.
void* pdeq_getl |
( |
pdeq * |
dq | ) |
|
Retrieve (and remove) a pointer from the left site of a double ended pointer list.
- Parameters
-
- Returns
- The pointer element.
void* pdeq_getr |
( |
pdeq * |
dq | ) |
|
Retrieve (and remove) a pointer from the right site of a double ended pointer list.
- Parameters
-
- Returns
- The pointer element.
size_t pdeq_len |
( |
pdeq const * |
dq | ) |
|
Returns the length of a double ended pointer list.
- Parameters
-
pdeq* pdeq_putl |
( |
pdeq * |
dq, |
|
|
const void * |
x |
|
) |
| |
Add a pointer to the left side of a double ended pointer list.
- Parameters
-
dq | The list to add a pointer to. |
x | The pointer element to be added |
- Returns
- The list.
pdeq* pdeq_putr |
( |
pdeq * |
dq, |
|
|
const void * |
x |
|
) |
| |
Add a pointer to the right side of a double ended pointer list.
- Parameters
-
dq | The list to add a pointer to. |
x | The pointer element to be added |
- Returns
- The list.
void* pdeq_search |
( |
pdeq const * |
qp, |
|
|
cmp_fun |
cmp, |
|
|
const void * |
key |
|
) |
| |
Search a key in a double ended pointer list, the search is controlled by a compare function.
An element is found, if the compare function returns 0. The search is started from the left site of the list.
- Parameters
-
qp | The list. |
cmp | The compare function. |
key | The search key. |
- Returns
- The address of the element entry if the key was found, NULL else.