offbrand
A collection of generic, reference counted datastructures in C for C
|
obdeque Public Interface More...
#include "offbrand.h"
Go to the source code of this file.
Typedefs | |
typedef struct obdeque_struct | obdeque |
typedef struct obdeque_iterator_struct | obdeque_iterator |
Functions | |
obdeque * | obdeque_new (void) |
Constructor, creates a new instance of obdeque with no contents. More... | |
obdeque * | obdeque_copy (const obdeque *to_copy) |
Copy Constructor, creates a new obdeque that contains the same contents as an obdeque instance. More... | |
uint8_t | obdeque_is_empty (const obdeque *deque) |
The emptyness state of an obdeque, either empty or non-empty. More... | |
uint64_t | obdeque_length (const obdeque *deque) |
Number of elements stored within an obdeque. More... | |
obdeque_iterator * | obdeque_head_iterator (const obdeque *deque) |
Constructor for an iterator for an obdeque that is directed at the head of the obdeque. More... | |
obdeque_iterator * | obdeque_tail_iterator (const obdeque *deque) |
Constructor for an iterator for an obdeque that is directed at the tail of the obdeque. More... | |
obdeque_iterator * | obdeque_copy_iterator (const obdeque_iterator *it) |
Copy Constructor for an obdeque_iterator from another obdeque_iterator. More... | |
uint8_t | obdeque_iterate_next (const obdeque *deque, obdeque_iterator *it) |
Advance an obdeque_iterator bound to an obdeque to the next element within the obdeque closer to the tail of the obdeque. More... | |
uint8_t | obdeque_iterate_prev (const obdeque *deque, obdeque_iterator *it) |
Advance an obdeque_iterator bound to an obdeque to the previous element within the obdeque closer to the obdeque head. More... | |
void | obdeque_add_at_head (obdeque *deque, obj *to_add) |
Add an obj to the head of an obdeque. More... | |
void | obdeque_add_at_tail (obdeque *deque, obj *to_add) |
Add an obj to the tail of an obdeque. More... | |
void | obdeque_add_at_iterator (obdeque *deque, obdeque_iterator *it, obj *to_add) |
Add an obj to an obdeque at position before the element specified by an obdeque_iterator. More... | |
obdeque * | obdeque_join (const obdeque *d1, const obdeque *d2) |
creates a new obdeque that contains the ordered contents of two obdeques More... | |
uint8_t | obdeque_find_obj (const obdeque *deque, const obj *to_find) |
Searches an obdeque for an obj. More... | |
void | obdeque_sort (obdeque *deque, int8_t order) |
Sorts an obdeque from least-to-greatest or greatest-to-least using the standard compare function. More... | |
void | obdeque_sort_with_funct (obdeque *deque, int8_t order, ob_compare_fptr funct) |
Sorts an obdeque from least-to-greatest or greatest-to-least using a specified comparision function. More... | |
obj * | obdeque_obj_at_head (const obdeque *deque) |
Peek at the obj stored at the head of an obdeque. More... | |
obj * | obdeque_obj_at_tail (const obdeque *deque) |
Peek at the obj stored at the tail of an obdeque. More... | |
obj * | obdeque_obj_at_iterator (const obdeque *deque, const obdeque_iterator *it) |
Peek at the obj stored within a obdeque stored at the position denoted by an obdeque_iterator bound to that obdeque. More... | |
void | obdeque_remove_head (obdeque *deque) |
Remove the obj stored at the head of an obdeque, shrinking the obdeque by one element. More... | |
void | obdeque_remove_tail (obdeque *deque) |
Remove the obj stored at the tail of an obdeque, shrinking the obdeque by one element. More... | |
void | obdeque_remove_at_iterator (obdeque *deque, obdeque_iterator *it) |
Remove the obj stored within an obdeque at the position denoted by the obdeque_iterator bound to that obdeque, shrinking the obdeque by one element. More... | |
void | obdeque_clear (obdeque *deque) |
removes all obj's from the Deque, leaving the Deque empty More... | |
obdeque Public Interface
typedef struct obdeque_struct obdeque |
Class type declaration
typedef struct obdeque_iterator_struct obdeque_iterator |
Class specific iterator type declaration.
Add an obj to the head of an obdeque.
deque | An instance of obdeque |
to_add | Any instance of an Offbrand compatible class to add to deque |
void obdeque_add_at_iterator | ( | obdeque * | deque, |
obdeque_iterator * | it, | ||
obj * | to_add | ||
) |
Add an obj to an obdeque at position before the element specified by an obdeque_iterator.
deque | An instance of obdeque |
it | An instance of obdeque_iterator bound to deque |
to_add | Any instance of an Offbrand compatible class to add to deque |
Add an obj to the tail of an obdeque.
deque | An instance of obdeque |
to_add | Any instance of an Offbrand compatible class to add to deque |
void obdeque_clear | ( | obdeque * | deque) |
removes all obj's from the Deque, leaving the Deque empty
deque | An instance of obdeque |
Copy Constructor, creates a new obdeque that contains the same contents as an obdeque instance.
to_copy | An instance of obdeque to copy |
obdeque_iterator* obdeque_copy_iterator | ( | const obdeque_iterator * | it) |
Copy Constructor for an obdeque_iterator from another obdeque_iterator.
it | An instance of obdeque_iterator |
Searches an obdeque for an obj.
deque | An instance of obdeque |
to_find | An instance of any Offbrand compatible class to search for within the deque |
0 | to_find not found within deque |
1 | to_find found within the deque |
obdeque_iterator* obdeque_head_iterator | ( | const obdeque * | deque) |
Constructor for an iterator for an obdeque that is directed at the head of the obdeque.
deque | An instance of obdeque |
NULL | The obdeque provided is empty and cannot be iterated |
non-NULL | An obdeque_iterator instance bound to the provided instance of obdeque and directed at the head of that obdeque |
uint8_t obdeque_is_empty | ( | const obdeque * | deque) |
The emptyness state of an obdeque, either empty or non-empty.
deque | An instance of obdeque |
0 | The deque is empty |
non-zero | The deque contains elements |
uint8_t obdeque_iterate_next | ( | const obdeque * | deque, |
obdeque_iterator * | it | ||
) |
Advance an obdeque_iterator bound to an obdeque to the next element within the obdeque closer to the tail of the obdeque.
deque | An instance of obdeque |
it | An intstance of obdeque_iterator that is bound to deque |
non-zero | Advancement was successful. |
0 | Advancement failed because no more elements exist in the obdeque closer to the deque tail |
uint8_t obdeque_iterate_prev | ( | const obdeque * | deque, |
obdeque_iterator * | it | ||
) |
Advance an obdeque_iterator bound to an obdeque to the previous element within the obdeque closer to the obdeque head.
deque | An instance of obdeque |
it | An intstance of obdeque_iterator that is bound to deque |
non-zero | Advancement was successful. |
0 | Advancement failed because no more elements exist in the obdeque closer to the deque head |
creates a new obdeque that contains the ordered contents of two obdeques
d1 | First obdeque to copy into the resultant obdeque |
d2 | Second obdeque to copy onto the end of the resultant obdeque |
uint64_t obdeque_length | ( | const obdeque * | deque) |
Number of elements stored within an obdeque.
deque | An instance of obdeque |
obdeque* obdeque_new | ( | void | ) |
Constructor, creates a new instance of obdeque with no contents.
Peek at the obj stored at the head of an obdeque.
deque | An instance of obdeque |
NULL | No elements exist within deque |
non-NULL | The element stored at the head of deque |
obj* obdeque_obj_at_iterator | ( | const obdeque * | deque, |
const obdeque_iterator * | it | ||
) |
Peek at the obj stored within a obdeque stored at the position denoted by an obdeque_iterator bound to that obdeque.
deque | An instance of obdeque |
it | An instance of obdeque_iterator bound to deque |
NULL | No elements exist within deque |
non-NULL | The element stored at the tail of deque |
Peek at the obj stored at the tail of an obdeque.
deque | An instance of obdeque |
NULL | No elements exist within deque |
non-NULL | The element stored at the tail of deque |
void obdeque_remove_at_iterator | ( | obdeque * | deque, |
obdeque_iterator * | it | ||
) |
Remove the obj stored within an obdeque at the position denoted by the obdeque_iterator bound to that obdeque, shrinking the obdeque by one element.
deque | An instance of obdeque |
it | An instance of obdeque_iterator bound to deque |
The provided obdeque_iterator will be advanced toward the obdeque tail, unless removing the tail then it will be advanced to the element before the tail (NULL if no more elements exist)
void obdeque_remove_head | ( | obdeque * | deque) |
Remove the obj stored at the head of an obdeque, shrinking the obdeque by one element.
deque | An instance of obdeque |
void obdeque_remove_tail | ( | obdeque * | deque) |
Remove the obj stored at the tail of an obdeque, shrinking the obdeque by one element.
deque | An instance of obdeque |
void obdeque_sort | ( | obdeque * | deque, |
int8_t | order | ||
) |
Sorts an obdeque from least-to-greatest or greatest-to-least using the standard compare function.
deque | An instance of obdeque |
order | Accepts OB_LEAST_TO_GREATEST or OB_GREATEST_TO_LEAST as valid sorting orders |
void obdeque_sort_with_funct | ( | obdeque * | deque, |
int8_t | order, | ||
ob_compare_fptr | funct | ||
) |
Sorts an obdeque from least-to-greatest or greatest-to-least using a specified comparision function.
deque | An instance of obdeque |
order | Accepts OB_LEAST_TO_GREATEST or OB_GREATEST_TO_LEAST as valid sorting orders |
funct | A pointer to a comparision function that returns a int8_t when given two obj * arguments |
obdeque_iterator* obdeque_tail_iterator | ( | const obdeque * | deque) |
Constructor for an iterator for an obdeque that is directed at the tail of the obdeque.
deque | An instance of obdeque |
NULL | The obdeque provided is empty and cannot be iterated |
non-NULL | An obdeque_iterator instance bound to the provided instance and directed at the tail of that obdeque |