Structure of the XanLib. More...
#include <semaphore.h>
#include <pthread.h>
#include <stddef.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | XanListItem |
List element. More... | |
struct | XanList |
Doubly linked list. More... | |
struct | XanVar |
Variable. More... | |
struct | XanPipe |
Pipe. More... | |
struct | XanStack |
Stack. More... | |
struct | XanNode |
Node of a generic tree. More... | |
struct | XanHashTableItem |
Element of the hash table. More... | |
struct | XanHashTable |
Hash table. More... | |
struct | XanBitSet |
Typedefs | |
typedef struct XanListItem | XanListItem |
List element. | |
typedef struct XanList | XanList |
Doubly linked list. | |
typedef struct XanVar | XanVar |
Variable. | |
typedef struct XanPipe | XanPipe |
Pipe. | |
typedef struct XanStack | XanStack |
Stack. | |
typedef struct XanNode | XanNode |
Node of a generic tree. | |
typedef struct XanHashTableItem | XanHashTableItem |
Element of the hash table. | |
typedef struct XanHashTable | XanHashTable |
Hash table. | |
typedef struct XanBitSet | XanBitSet |
Functions | |
bool | xanStackSynchContains (XanStack *stack, void *element) |
bool | xanStackContains (XanStack *stack, void *element) |
XanList * | XanHashTable_ToItemList (XanHashTable *table) |
From HashTable to List. | |
XanList * | xanListNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr), void *(*cloneFunction)(void *addr)) |
Make a new list. | |
XanVar * | xanVarNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr)) |
Make a new variable. | |
XanPipe * | xanPipeNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr)) |
Make a new pipe. | |
XanNode * | xanNodeNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr), void *(*cloneFunction)(void *data)) |
Make a new node. | |
XanStack * | xanStackNew (void *(*allocFunction)(size_t size), void(*freeFunction)(void *addr), void *(*cloneFunction)(void *data)) |
XanHashTable * | xanHashTableNew (unsigned int length, int hasFixedLength, void *(*allocFunction)(size_t size), void *(*reallocFunction)(void *addr, size_t newSize), void(*freeFunction)(void *addr), unsigned int(*hashFunction)(void *element), int(*equalsFunction)(void *key1, void *key2)) |
Make a new Hash Table. | |
void | print_err (char *message, int err) |
Print an error message. | |
void | print_ascii_err (signed char *message, int err) |
Print an error message. | |
int | str_has_suffix (char *string, char *suffix) |
void | libxanCompilationFlags (char *buffer, int bufferLength) |
void | libxanCompilationTime (char *buffer, int bufferLength) |
char * | libxanVersion () |
XanBitSet * | XanBitSet_Alloc (size_t length) |
allocate a bitset structure in memory and return a pointer | |
void | XanBitSet_ClearAll (XanBitSet *set) |
set to 0 all the bits in the bitset | |
void | XanBitSet_SetAll (XanBitSet *set) |
set to 1 all the bits in the bitset | |
void | XanBitSet_Subtract (XanBitSet *fromThis, XanBitSet *subtractThis) |
void | XanBitSet_Free (XanBitSet *set) |
release the memory used for the bitset | |
void | XanBitSet_Intersect (XanBitSet *dest, XanBitSet *src) |
compute the intersection between dest and src and assign it to dest | |
int | XanBitSet_GetCountOfBitsSet (XanBitSet *set) |
compute the number of bit that are set in the xan_bitset | |
bool | XanBitSet_Equal (XanBitSet *bs1, XanBitSet *bs2) |
test if bs1 is equal to bs2 | |
XanBitSet * | XanBitSet_Clone (XanBitSet *src) |
clone src and return it | |
void | XanBitSet_Copy (XanBitSet *dest, XanBitSet *src) |
void | XanBitSet_ClearBit (XanBitSet *set, size_t pos) |
set the pos-st bit to 0 | |
void | XanBitSet_SetBit (XanBitSet *set, size_t pos) |
set the pos-st bit to 1 | |
bool | XanBitSet_IsBitSet (XanBitSet *set, size_t pos) |
return the value of the pos-th bit (1 if it is set, 0 otherwise) | |
bool | XanBitSet_IsSubSetOf (XanBitSet *setA, XanBitSet *setB) |
Check wheter setA is a subset of setB. In particular, even if setA and setB contain exactly the same elements true is returned. setA and setB must be of the same length. | |
void | XanBitSet_Print (XanBitSet *set, int cr) |
print the XanBitSet to the standard output. Set cr if you want a newline |
Structure of the XanLib.
Structure of the XanLib
Definition in file xanlib.h.
typedef struct XanHashTable XanHashTable |
Hash table.
This structure implements the closed hash table. The equals, hash functions can be customized by the user.
typedef struct XanHashTableItem XanHashTableItem |
Element of the hash table.
Doubly linked list.
Doubly linked list containing pointers to user data with the ability to iterate over the list in both directions.
typedef struct XanListItem XanListItem |
List element.
Element stored inside the XanList list
Node of a generic tree.
The XanNode structure implements a generic N-ary tree.
Pipe.
This is a pipe structure, which can store inside itself unbounded elements.
Stack.
This is a stack structure. This is a queue with the LIFO (Last In First Out) policy.
void libxanCompilationFlags | ( | char * | buffer, | |
int | bufferLength | |||
) |
void libxanCompilationTime | ( | char * | buffer, | |
int | bufferLength | |||
) |
void print_ascii_err | ( | signed char * | message, | |
int | err | |||
) |
Print an error message.
Print to stderr the error message given as input. If the err parameter is different from zero, then it append to the message the error message given bound to the err number.
message | The error message to print | |
err | The errno number given by the Linux system |
Definition at line 2995 of file xanlib.c.
References print_err().
void print_err | ( | char * | message, | |
int | err | |||
) |
Print an error message.
Print to stderr the error message given as input. If the err parameter is different from zero, then it append to the message the error message given bound to the err number.
message | The error message to print | |
err | The errno number given by the Linux system |
Definition at line 2999 of file xanlib.c.
Referenced by _xanHashTableDelete(), _xanHashTableInsert(), _xanListDelete(), and print_ascii_err().
XanBitSet* XanBitSet_Alloc | ( | size_t | length | ) |
allocate a bitset structure in memory and return a pointer
Definition at line 3316 of file xanlib.c.
References WORDS_NECESSARY.
Referenced by XanBitSet_Clone().
void XanBitSet_ClearAll | ( | XanBitSet * | set | ) |
set to 0 all the bits in the bitset
Definition at line 3377 of file xanlib.c.
References WORDS_NECESSARY.
void XanBitSet_ClearBit | ( | XanBitSet * | set, | |
size_t | pos | |||
) |
clone src and return it
Definition at line 3357 of file xanlib.c.
References XanBitSet::data, XanBitSet::length, WORDS_NECESSARY, and XanBitSet_Alloc().
Definition at line 3364 of file xanlib.c.
References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.
test if bs1 is equal to bs2
Definition at line 3352 of file xanlib.c.
References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.
void XanBitSet_Free | ( | XanBitSet * | set | ) |
int XanBitSet_GetCountOfBitsSet | ( | XanBitSet * | set | ) |
compute the number of bit that are set in the xan_bitset
Definition at line 3335 of file xanlib.c.
References XanBitSet_IsBitSet().
compute the intersection between dest and src and assign it to dest
Definition at line 3329 of file xanlib.c.
References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.
bool XanBitSet_IsBitSet | ( | XanBitSet * | set, | |
size_t | pos | |||
) |
return the value of the pos-th bit (1 if it is set, 0 otherwise)
Definition at line 3422 of file xanlib.c.
References is_bit_set().
Referenced by XanBitSet_GetCountOfBitsSet().
Check wheter setA is a subset of setB. In particular, even if setA and setB contain exactly the same elements true is returned. setA and setB must be of the same length.
Definition at line 3427 of file xanlib.c.
References is_bit_set(), and XanBitSet::length.
void XanBitSet_Print | ( | XanBitSet * | set, | |
int | cr | |||
) |
print the XanBitSet to the standard output. Set cr if you want a newline
Definition at line 3369 of file xanlib.c.
References MASK, and WORD_NUMBER.
void XanBitSet_SetAll | ( | XanBitSet * | set | ) |
set to 1 all the bits in the bitset
Definition at line 3382 of file xanlib.c.
References WORDS_NECESSARY.
void XanBitSet_SetBit | ( | XanBitSet * | set, | |
size_t | pos | |||
) |
Definition at line 3387 of file xanlib.c.
References XanBitSet::data, XanBitSet::length, and WORDS_NECESSARY.
XanList* XanHashTable_ToItemList | ( | XanHashTable * | table | ) |
From HashTable to List.
Returns the list of element and elementID pairs (in the form of XanHashTableItem) that are part of the hashtable. These are only copies of the XanHashTableItems of the hashtable, and modifing them does not affect the original hashtable. Each of the Items has to be deallocated while deallocating the XanList (e.g. calling the function destroyListAndData of the XanList data structure).
Definition at line 2660 of file xanlib.c.
References _xanListInsert(), XanHashTable::alloc, XanHashTable::free, XanHashTable::length, XanHashTableItem::next, XanHashTable::table, XanHashTableItem::used, and xanListNew().
XanHashTable* xanHashTableNew | ( | unsigned int | length, | |
int | hasFixedLength, | |||
void *(*)(size_t size) | allocFunction, | |||
void *(*)(void *addr, size_t newSize) | reallocFunction, | |||
void(*)(void *addr) | freeFunction, | |||
unsigned int(*)(void *element) | hashFunction, | |||
int(*)(void *key1, void *key2) | equalsFunction | |||
) |
Make a new Hash Table.
Allocate and initialize a new Hash table. After the allocation, the hash and equals functions cannot be changed.
Definition at line 2361 of file xanlib.c.
References _xanHashTableCloneHashTable(), _xanHashTableDelete(), _xanHashTableDestroy(), _xanHashTableElementsInside(), _xanHashTableGetCloneFunction(), _xanHashTableInsert(), _xanHashTableLock(), _xanHashTableLookup(), _xanHashTableSetCloneFunction(), _xanHashTableToList(), _xanHashTableToSlotList(), _xanHashTableUnlock(), XanHashTable::alloc, XanHashTable::clone, XanHashTable::cloneHashTable, XanHashTable::currentLoadFactor, XanHashTable::delete, XanHashTable::destroy, XanHashTable::elementsInside, XanHashTable::equals, XanHashTable::free, XanHashTable::getCloneFunction, XanHashTable::hasFixedLength, XanHashTable::hash, XanHashTable::insert, XanHashTable::length, XanHashTable::lock, XanHashTable::lookup, XanHashTable::mutex, XanHashTable::primeIndex, primes, PRIMES_TABLE_LENGTH, XanHashTable::realloc, XanHashTable::setCloneFunction, XanHashTable::size, XanHashTable::synchCloneHashTable, XanHashTable::synchDelete, XanHashTable::synchDestroy, XanHashTable::synchElementsInside, XanHashTable::synchGetCloneFunction, XanHashTable::synchInsert, XanHashTable::synchLookup, XanHashTable::synchSetCloneFunction, XanHashTable::synchToList, XanHashTable::synchToSlotList, XanHashTable::table, XanHashTable::toList, XanHashTable::toSlotList, XanHashTable::unlock, xanHashTableCloneHashTable(), xanHashTableDefaultEqualsFunction(), xanHashTableDefaultHashFunction(), xanHashTableDelete(), xanHashTableDestroy(), xanHashTableElementsInside(), xanHashTableGetCloneFunction(), xanHashTableInsert(), xanHashTableLookup(), xanHashTableSetCloneFunction(), xanHashTableToList(), and xanHashTableToSlotList().
Referenced by _xanHashTableCloneHashTable().
XanList* xanListNew | ( | void *(*)(size_t size) | allocFunction, | |
void(*)(void *addr) | freeFunction, | |||
void *(*)(void *addr) | cloneFunction | |||
) |
Make a new list.
Make a new list. e.g. XanList *myList = xanListNew(malloc, free, NULL);
allocFunction | This function is called each time the list needs to allocate new memory; if it is NULL, then the list will use the malloc function. | |
freeFunction | This function is called each time the list needs to free memory; if it is NULL, then the list will use the free function. | |
cloneFunction | This function is called each time the list needs to clone the variable stored inside its elements; if it is NULL, then the list does not clone the variable stored inside each element of the list. |
Definition at line 637 of file xanlib.c.
References _xanListAppend(), _xanListAppendList(), _xanListCloneList(), _xanListContainsTheSameElements(), _xanListData(), _xanListDelete(), _xanListDeleteAll(), _xanListDeleteClones(), _xanListDeleteItem(), _xanListDestroy(), _xanListDestroyListAndData(), _xanListEmptyOutList(), _xanListEqualsInstancesNumber(), _xanListFind(), _xanListFirst(), _xanListGetCloneFunction(), _xanListGetElementFromPositionNumber(), _xanListGetSlotData(), _xanListInsert(), _xanListInsertAfter(), _xanListInsertBefore(), _xanListLast(), _xanListLength(), _xanListLock(), _xanListMoveToBegin(), _xanListNext(), _xanListPrev(), _xanListSetCloneFunction(), _xanListShareSomeElements(), _xanListUnlock(), XanList::alloc, XanList::append, XanList::appendList, XanList::clone, XanList::cloneList, XanList::containsTheSameElements, XanList::data, XanList::delete, XanList::deleteAll, XanList::deleteClones, XanList::deleteItem, XanList::destroyList, XanList::destroyListAndData, XanList::emptyOutList, XanList::equalsInstancesNumber, XanList::find, XanList::first, XanList::firstItem, XanList::free, XanList::getCloneFunction, XanList::getElementFromPositionNumber, XanList::getSlotData, XanList::insert, XanList::insertAfter, XanList::insertBefore, XanList::itemsMutex, XanList::last, XanList::lastItem, XanList::len, XanList::length, XanList::lock, XanList::moveToBegin, XanList::next, XanList::prev, XanList::setCloneFunction, XanList::shareSomeElements, XanList::synchAppend, XanList::synchAppendList, XanList::synchCloneList, XanList::synchContainsTheSameElements, XanList::synchData, XanList::synchDelete, XanList::synchDeleteAll, XanList::synchDeleteClones, XanList::synchDeleteItem, XanList::synchDestroyList, XanList::synchDestroyListAndData, XanList::synchEmptyOutList, XanList::synchEqualsInstancesNumber, XanList::synchFind, XanList::synchFirst, XanList::synchGetCloneFunction, XanList::synchGetElementFromPositionNumber, XanList::synchGetSlotData, XanList::synchInsert, XanList::synchInsertAfter, XanList::synchInsertBefore, XanList::synchLast, XanList::synchLength, XanList::synchMoveToBegin, XanList::synchNext, XanList::synchPrev, XanList::synchSetCloneFunction, XanList::synchShareSomeElements, XanList::unlock, xanListAppend(), xanListAppendList(), xanListCloneList(), xanListContainsTheSameElements(), xanListData(), xanListDelete(), xanListDeleteAll(), xanListDeleteClones(), xanListDeleteItem(), xanListDestroy(), xanListDestroyListAndData(), xanListEmptyOutList(), xanListEqualsInstancesNumber(), xanListFind(), xanListFirst(), xanListGetCloneFunction(), xanListGetElementFromPositionNumber(), xanListGetSlotData(), xanListInsert(), xanListInsertAfter(), xanListInsertBefore(), xanListLast(), xanListLength(), xanListMoveToBegin(), xanListNext(), xanListPrev(), xanListSetCloneFunction(), and xanListShareSomeElements().
Referenced by _xanHashTableToList(), _xanHashTableToSlotList(), _xanListCloneList(), _xanNodeToInOrderList(), _xanNodeToPostOrderList(), _xanNodeToPreOrderList(), XanHashTable_ToItemList(), xanNodeNew(), xanPipeNew(), and xanStackNew().
XanNode* xanNodeNew | ( | void *(*)(size_t size) | allocFunction, | |
void(*)(void *addr) | freeFunction, | |||
void *(*)(void *data) | cloneFunction | |||
) |
Make a new node.
Make a new node of the N-ary tree.
allocFunction | This function is called each time the tree needs to allocate new memory; if it is NULL, then the tree will use the malloc function. | |
freeFunction | This function is called each time the tree needs to free memory; if it is NULL, then the tree will use the free function. | |
cloneFunction | This function is called each time the tree needs to clone the variable stored inside its elements; if it is NULL, then the tree does not clone the variable stored inside each element of the tree rooted at the current node. |
Definition at line 1785 of file xanlib.c.
References _xanNodeAddChildren(), _xanNodeAddNewChildren(), _xanNodeCloneTree(), _xanNodeDeleteChildren(), _xanNodeDestroyNode(), _xanNodeDestroyTree(), _xanNodeDestroyTreeAndData(), _xanNodeFind(), _xanNodeGetChildrens(), _xanNodeGetData(), _xanNodeGetNextChildren(), _xanNodeGetParent(), _xanNodeSetCloneFunction(), _xanNodeSetData(), _xanNodeSetParent(), _xanNodeToInOrderList(), _xanNodeToPostOrderList(), _xanNodeToPreOrderList(), XanNode::addChildren, XanNode::addNewChildren, XanNode::alloc, XanNode::childrens, XanNode::clone, XanNode::cloneTree, XanNode::data, XanNode::deleteChildren, XanNode::destroyNode, XanNode::destroyTree, XanNode::destroyTreeAndData, XanNode::find, XanNode::free, XanNode::getChildrens, XanNode::getData, XanNode::getNextChildren, XanNode::getParent, XanNode::mutex, XanNode::parent, XanNode::setCloneFunction, XanNode::setData, XanNode::setParent, XanNode::synchAddChildren, XanNode::synchAddNewChildren, XanNode::synchCloneTree, XanNode::synchDeleteChildren, XanNode::synchDestroyTree, XanNode::synchDestroyTreeAndData, XanNode::synchFind, XanNode::synchGetChildrens, XanNode::synchGetData, XanNode::synchGetNextChildren, XanNode::synchGetParent, XanNode::synchSetCloneFunction, XanNode::synchSetData, XanNode::synchSetParent, XanNode::synchToInOrderList, XanNode::synchToPostOrderList, XanNode::synchToPreOrderList, XanNode::toInOrderList, XanNode::toPostOrderList, XanNode::toPreOrderList, xanListNew(), xanNodeAddChildren(), xanNodeAddNewChildren(), xanNodeCloneTree(), xanNodeDeleteChildren(), xanNodeDestroyTree(), xanNodeDestroyTreeAndData(), xanNodeFind(), xanNodeGetChildrens(), xanNodeGetData(), xanNodeGetNextChildren(), xanNodeGetParent(), xanNodeSetCloneFunction(), xanNodeSetData(), xanNodeSetParent(), xanNodeToInOrderList(), xanNodeToPostOrderList(), and xanNodeToPreOrderList().
Referenced by _xanNodeAddNewChildren(), and _xanNodeCloneTree().
XanPipe* xanPipeNew | ( | void *(*)(size_t size) | allocFunction, | |
void(*)(void *addr) | freeFunction | |||
) |
Make a new pipe.
Make a new pipe.
allocFunction | This function is called each time the pipe needs to allocate new memory; if it is NULL, then the pipe will use the malloc function. | |
freeFunction | This function is called each time the pipe needs to free memory; if it is NULL, then the pipe will use the free function. |
Definition at line 1470 of file xanlib.c.
References _xanPipeDeleteItem(), _xanPipeDestroyPipe(), _xanPipeGet(), _xanPipeIsEmpty(), _xanPipeMoveToEnd(), _xanPipePut(), _xanPipePutAtEnd(), XanPipe::alloc, XanPipe::deleteItem, XanPipe::destroyPipe, XanPipe::free, XanPipe::get, XanPipe::isEmpty, XanPipe::items, XanPipe::itemsCond, XanPipe::itemsMutex, XanPipe::lock, XanPipe::moveToEnd, XanPipe::put, XanPipe::putAtEnd, XanPipe::synchDeleteItem, XanPipe::synchGet, XanPipe::synchIsEmpty, XanPipe::synchMoveToEnd, XanPipe::synchPut, XanPipe::synchPutAtEnd, XanPipe::unlock, xanListNew(), xanPipeDeleteItem(), xanPipeGet(), xanPipeIsEmpty(), xanPipeLock(), xanPipeMoveToEnd(), xanPipePut(), xanPipePutAtEnd(), and xanPipeUnlock().
bool xanStackContains | ( | XanStack * | stack, | |
void * | element | |||
) |
Definition at line 3182 of file xanlib.c.
References _xanListFind(), and XanStack::internalList.
Referenced by xanStackSynchContains().
XanStack* xanStackNew | ( | void *(*)(size_t size) | allocFunction, | |
void(*)(void *addr) | freeFunction, | |||
void *(*)(void *data) | cloneFunction | |||
) |
Definition at line 1758 of file xanlib.c.
References _xanStackDestroyStack(), _xanStackGetSize(), _xanStackPop(), _xanStackPush(), XanStack::destroyStack, XanStack::getSize, XanStack::internalList, XanStack::mutex, XanStack::pop, XanStack::push, XanStack::synchGetSize, XanStack::synchPop, XanStack::synchPush, xanListNew(), xanStackGetSize(), xanStackPop(), and xanStackPush().
bool xanStackSynchContains | ( | XanStack * | stack, | |
void * | element | |||
) |
Definition at line 3198 of file xanlib.c.
References XanStack::mutex, and xanStackContains().
XanVar* xanVarNew | ( | void *(*)(size_t size) | allocFunction, | |
void(*)(void *addr) | freeFunction | |||
) |
Make a new variable.
Make a new variable.
allocFunction | This function is called each time the variable needs to allocate new memory; if it is NULL, then the variable will use the malloc function. | |
freeFunction | This function is called each time the variable needs to free memory; if it is NULL, then the variable will use the free function. |
Definition at line 1386 of file xanlib.c.
References _varRead(), _varWrite(), XanVar::alloc, XanVar::data, XanVar::destroyVarAndData, XanVar::free, XanVar::lock, XanVar::mutex, XanVar::read, XanVar::synchRead, XanVar::synchWrite, XanVar::unlock, varDestroyVarAndData(), varLock(), varRead(), varUnlock(), varWrite(), and XanVar::write.