libFirm
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Double Ended Queue

Implementation if a double ended queue data structure for generic pointers. More...

Typedefs

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...
 

Functions

pdeqnew_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...
 
pdeqpdeq_putl (pdeq *dq, const void *x)
 Add a pointer to the left side of a double ended pointer list. More...
 
pdeqpdeq_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...
 

Detailed Description

Implementation if a double ended queue data structure for generic pointers.

Typedef Documentation

typedef int(* cmp_fun)(const void *elem, const void *key)

The type of the pointer compare function.

Parameters
elemThe list element.
keyThe user supplied key.
Returns
0 if the element matches the key, non-zero else.

Definition at line 33 of file pdeq.h.

typedef struct pdeq pdeq

The pointer double ended queue (list).

Definition at line 38 of file pdeq.h.

Function Documentation

void del_pdeq ( pdeq dq)

Delete a double ended pointer list.

Parameters
dqThe list to be deleted.
pdeq* new_pdeq ( void  )

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
dqThe list.
xThe 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
qpThe list.
dstA 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
qpThe list.
dstA 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
dqThe list.
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
dqThe list
Returns
The pointer element.
Remarks
This function will fail if the list is empty.
void* pdeq_getr ( pdeq dq)

Retrieve (and remove) a pointer from the right site of a double ended pointer list.

Parameters
dqThe list
Returns
The pointer element.
Remarks
This function will fail if the list is empty.
size_t pdeq_len ( pdeq const *  dq)

Returns the length of a double ended pointer list.

Parameters
dqThe list.
pdeq* pdeq_putl ( pdeq dq,
const void *  x 
)

Add a pointer to the left side of a double ended pointer list.

Parameters
dqThe list to add a pointer to.
xThe 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
dqThe list to add a pointer to.
xThe 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
qpThe list.
cmpThe compare function.
keyThe search key.
Returns
The address of the element entry if the key was found, NULL else.