Linux Assemblycollection of fast libraries

Deque ADTDeque.h

Double-ended queue (deque) is an abstract data type that generalizes a queue, for which elements can be added to or removed from either the front (head) or back (tail). This differs from the queue abstract data type, where elements can only be added to one end and removed from the other. Deque data class has some additional forms:

  • An input-restricted deque is one where deletion can be made from both ends, but insertion can be made at one end only.
  • An output-restricted deque is one where insertion can be made at both ends, but deletion can be made from one end only.

Contents

Function list

C function nameAccess typeC++ function nameAccess type
AllowReadingsRW(constructor) DequeRW
AllowWritingsRW(copy constructor) DequeRW
CapacityRO(destructor) ~DequeRW
CompareROAllowReadingsRW
CompareFunctionROAllowWritingsRW
CopyDequeRWCapacityRO
CopyFunctionROCompareRO
CopyHeadRWCompareFunctionRO
CopyTailRWCopyFunctionRO
CountKeyHeadROCopyHeadRW
CountKeyTailROCopyTailRW
CountKeysHeadROCountKeyHeadRO
CountKeysTailROCountKeyTailRO
DeleteFunctionROCountKeysHeadRO
ExtractHeadRWCountKeysTailRO
ExtractTailRWDeleteFunctionRO
FindDiffHeadROExtractHeadRW
FindDiffTailROExtractTailRW
FindKeyHeadROFindDiffHeadRO
FindKeyTailROFindDiffTailRO
FindKeysHeadROFindKeyHeadRO
FindKeysTailROFindKeyTailRO
FreeDequeRWFindKeysHeadRO
GetHeadROFindKeysTailRO
GetTailROGetHeadRO
InitDequeRWGetTailRO
InsertHeadRWInsertHeadRW
InsertTailRWInsertTailRW
IsEmptyROIsEmptyRO
IsEqualROIsEqualRO
IsInitROIsInitRO
KeyTypeROKeyTypeRO
LockReadingsRWLockReadingsRW
LockWritingsRWLockWritingsRW
MaxHeadROMaxHeadRO
MaxTailROMaxTailRO
MinHeadROMinHeadRO
MinTailROMinTailRO
MoveHeadRWMoveHeadRW
MoveTailRWMoveTailRW
PopHeadRWPopHeadRW
PopTailRWPopTailRW
PushHeadRWPushHeadRW
PushTailRWPushTailRW
ReverseHeadRWReverseHeadRW
ReverseTailRWReverseTailRW
SetHeadRWSetHeadRW
SetTailRWSetTailRW
SizeROSizeRO
SwapHeadRWSwapHeadRW
SwapTailRWSwapTailRW
UserDataROUserDataRO
C function nameAccess typeC++ function nameAccess type

Constructor

Cvoid Deque_InitDeque (struct Deque *deque, size_t capacity, CopyFunc cfunc, DelFunc dfunc, void *ptr);
C++Deque::Deque (size_t capacity, CopyFunc cfunc, DelFunc dfunc, void *ptr);

Description: Init new deque instance.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • capacity - initial count of elements that the deque can hold. Deque capacity is auto extended if required.
  • cfunc - pointer to copy function for element fields: key and data, or NULL. Copy function should follow this prototype.
  • dfunc - pointer to delete function to call for removing elements, or NULL. Delete function should follow this prototype.
  • ptr - pointer to user's data, required by element copy and delete functions, or NULL.

Return value: None.

Copy constructor

Cvoid Deque_CopyDeque (struct Deque *deque, const struct Deque *source);
C++Deque::Deque (const Deque &source);

Description: Init new instance of the deque and copy all elements from the source deque inside the new one. New deque has its own data space and doesn't share any memory blocks with the source deque. Source deque stay unchanged and accessed in read only mode.

Access type: RW

Parameters:

  • accumulator - pointer to target deque
  • source - pointer to source deque

Return value: None.

Destructor

Cvoid Deque_FreeDeque (struct Deque *deque);
C++Deque::~Deque (void);

Description: Reset the deque instance and release all memory blocks are used by the object.

Access type: RW

Parameters:

  • deque - pointer to the deque

Return value: None.

Access predicates

Access predicates is an easy and efficient way to write multithreaded highly concurrent code. Deque functions may change container elements, add new values and remove the existing ones. This can result to data inconsistency among different threads. To solve this possible issue, you have to separate read and write operations to the deque. Write operation can not be invoked in the same time with other write or read operations, and should get exclusive access to the container. Read operations can be processed simultaneously with each other, but not with write operation (because of possible dirty reads).

Access predicates solve these problems and support lock methods for exclusive writes and concurrent reads from different threads. Lock functions return TRUE state only when you get appropriate access to the deque. They support wait and no wait behaviors. If wait flag is set, then lock functions wait until the lock is taken. In no wait mode they try to get lock for some short period of time (spinlock cycle). And if no success, then return FALSE. Your code may check the return status and do something else instead of just waiting.

Lock operations

Lock operations give you appropriate access type to the deque and return TRUE, if you get such access, or FALSE, if lock is taken by other thread, and you chose no wait behavior (wait flag is set to FALSE). You can check lock status and run some code while other threads hold the lock. If the thread get the lock, then you can be sure that other threads do not process unsafe operations on the container. To guarantee this other threads also should use lock functions and check returned lock result. When you complete the operations, then release the lock by calling release functions, described below. This will wake up waiting threads for further data processing.

Exclusive access

Cbool Deque_LockReadings (struct Deque *deque, bool wait);
C++bool Deque::LockReadings (bool wait);

Description: Lock read and write operations from other threads and provide exclusive access for deque modifications. All other threads are waiting until the lock is released by AllowReadings procedure. To guarantee that the thread has exclusive access, all concurrent threads also should use either of lock functions like LockReadings or LockWritings to wait.

Wait flag, is used by the functions, can change their behavior from always wait, until the lock is taken, to no wait behavior. No wait variant tries to get the lock in spinlock cycle, and if no success, then return FALSE state. User's code can check the functions status, and if exclusive lock is taken, then process the deque modifications, or do something else if lock is not taken.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • wait - wait flag. If set, then functions wait until lock is taken and always return TRUE.

Return value:

  • TRUE (1) if you have exclusive access to the deque.
  • FALSE (0) if the wait flag was not set and exclusive lock is not taken.

Warning:Exclusive lock operation is not recursive. It should be called only once and then released. Thread can do it many times but not in recursive mode.

Note:Do not forget to release exclusive lock when you finished. Use the AllowReadings procedure.

Read only access

Cbool Deque_LockWritings (struct Deque *deque, bool wait);
C++bool Deque::LockWritings (bool wait);

Description: Lock write operations from all threads and provide read only access to the deque. All write threads, are waiting until the lock is released by AllowWritings procedure. All reading threads continue to work. To guarantee that the thread has read only access, all concurrent threads also should use either of lock functions like LockReadings or LockWritings to wait.

Wait flag, is used by the functions, can change their behavior from always wait, until the lock is taken, to no wait behavior. No wait variant tries to get the lock in spinlock cycle, and if no success, then return FALSE state. User's code can check the functions status, and if read only lock is taken, then process the deque readings, or do something else if lock is not taken.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • wait - wait flag. If set, then functions wait until lock is taken and always return TRUE.

Return value:

  • TRUE (1) if you have read only access to the deque.
  • FALSE (0) if the wait flag was not set and read only lock is not taken.

Warning:Deque built in futex collects count of concurrent reading threads. So each succeed read lock should always have appropriate release call.

Note:Do not forget to release read only lock when you finished. Use the AllowWritings procedure.

Release operations

Release operations unlock the built in futex and wake up waiters for further data processing. AllowReadings procedure release exclusive lock and wake all writing and reading threads. AllowWritings procedure wake anyone of writing threads if the deque have any of them. Each lock function should always call release function to prevent dead locks.

Releasing of exclusive lock

Cvoid Deque_AllowReadings (struct Deque *deque);
C++void Deque::AllowReadings (void);

Description: Release exclusive lock and allow deque readings and writings from other threads.

Access type: RW

Parameters:

  • deque - pointer to the deque

Return value: None.

Releasing of read only lock

Cvoid Deque_AllowWritings (struct Deque *deque);
C++void Deque::AllowWritings (void);

Description: Release read only lock and allow deque writings from other threads. If you have multiple reading threads, then only the last reading thread really release the lock and wake up the writing thread.

Access type: RW

Parameters:

  • deque - pointer to the deque

Return value: None.

Warning:Deque built in futex collects count of concurrent reading threads. So each succeed read lock should always have appropriate release call.

Copying elements

Csize_t Deque_CopyHead (struct Deque *deque, size_t tpos, const struct Deque *source, size_t spos, size_t count);
size_t Deque_CopyTail (struct Deque *deque, size_t tpos, const struct Deque *source, size_t spos, size_t count);
C++size_t Deque::CopyHead (size_t tpos, const Deque *source, size_t spos, size_t count);
size_t Deque::CopyTail (size_t tpos, const Deque *source, size_t spos, size_t count);

Description: Copy "count" elements from source deque into head/tail of target deque. Source elements are iterated from head to tail ("CopyHead" functions), and from tail to head ("CopyTail" functions). Functions copy data starting from "spos" element after current position of source deque head/tail, until all "count" elements are inserted into target deque after "tpos" position. Source deque stay unchanged and accessed in read only mode.

Access type: RW

Parameters:

  • deque - pointer to target deque
  • tpos - insert position from the head/tail of target deque
  • source - pointer to source deque
  • spos - starting position from the head/tail of source deque
  • count - number of elements to copy (-1 means all available elements)

Return value:

  • Real count of elements, which were copied from source deque.
  • -1 if target deque was not able to extend its capacity for new elements, or starting position is greater than or equal to target/source deque size, or functions are called from read only section, started by LockWritings access predicate.

Moving elements

Csize_t Deque_MoveHead (struct Deque *deque, size_t tpos, struct Deque *source, size_t spos, size_t count);
size_t Deque_MoveTail (struct Deque *deque, size_t tpos, struct Deque *source, size_t spos, size_t count);
C++size_t Deque::MoveHead (size_t tpos, Deque *source, size_t spos, size_t count);
size_t Deque::MoveTail (size_t tpos, Deque *source, size_t spos, size_t count);

Description: Move "count" elements from source deque into head/tail of target deque. Source elements are iterated from head to tail ("MoveHead" functions), and from tail to head ("MoveTail" functions). Functions move data starting from "spos" element after current position of source deque head/tail, until all "count" elements are inserted into target deque after "tpos" position.

Access type: RW

Parameters:

  • deque - pointer to target deque
  • tpos - insert position from the head/tail of target deque
  • source - pointer to source deque
  • spos - starting position from the head/tail of source deque
  • count - number of elements to move (-1 means all available elements)

Return value:

  • Real count of elements, which were moved from source deque.
  • -1 if target deque was not able to extend its capacity for new elements, or starting position is greater than or equal to target/source deque size, or functions are called from read only section, started by LockWritings access predicate.

Addition of element

Cbool Deque_PushHead (struct Deque *deque, const struct pair_t *data);
bool Deque_PushTail (struct Deque *deque, const struct pair_t *data);
C++bool Deque::PushHead (const pair_t *data);
bool Deque::PushTail (const pair_t *data);

Description: Push new element into the deque head/tail.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • data - pointer to the new element

Return value:

  • TRUE (1) if element was successfully inserted into the deque.
  • FALSE (0) if the deque was not able to extend its capacity for the new element, or functions are called from read only section, started by LockWritings access predicate.

Removal of element

Cbool Deque_PopHead (struct Deque *deque);
bool Deque_PopTail (struct Deque *deque);
C++bool Deque::PopHead (void);
bool Deque::PopTail (void);

Description: Pop element from the deque head/tail.

Access type: RW

Parameters:

  • deque - pointer to the deque

Return value:

  • TRUE (1) if deque is not empty.
  • FALSE (0) if deque is empty, or functions are called from read only section, started by LockWritings access predicate.

Insertion of element

Cbool Deque_InsertHead (struct Deque *deque, const struct pair_t *data, size_t pos);
bool Deque_InsertTail (struct Deque *deque, const struct pair_t *data, size_t pos);
C++bool Deque::InsertHead (const pair_t *data, size_t pos);
bool Deque::InsertTail (const pair_t *data, size_t pos);

Description: Insert new element into the selected position from the deque head/tail.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • data - pointer to the new element
  • pos - element position in the deque

Return value:

  • TRUE (1) if element was successfully inserted into the deque.
  • FALSE (0) if the deque was not able to extend its capacity, or element position is incorrect, or functions are called from read only section, started by LockWritings access predicate.

Note:Position is calculated from the head/tail of the deque. The head/tail element has zero position.

Extraction of element

Cbool Deque_ExtractHead (struct Deque *deque, size_t pos);
bool Deque_ExtractTail (struct Deque *deque, size_t pos);
C++bool Deque::ExtractHead (size_t pos);
bool Deque::ExtractTail (size_t pos);

Description: Delete the element in the selected position from the deque head/tail.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • pos - element position in the deque

Return value:

  • TRUE (1) if element position is less than the deque size.
  • FALSE (0) if element position is incorrect, or functions are called from read only section, started by LockWritings access predicate.

Note:Position is calculated from the head/tail of the deque. The head/tail element has zero position.

Setting element value

Cbool Deque_SetHead (struct Deque *deque, const struct pair_t *data, size_t pos);
bool Deque_SetTail (struct Deque *deque, const struct pair_t *data, size_t pos);
C++bool Deque::SetHead (const pair_t *data, size_t pos);
bool Deque::SetTail (const pair_t *data, size_t pos);

Description: Set value of the element in selected position from the head/tail of the deque.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • data - pointer to the new value of the element
  • pos - element position in the deque from its head/tail

Return value:

  • TRUE (1) if element position is less than the deque size.
  • FALSE (0) if element with target position does not exist, or functions are called from read only section, started by LockWritings access predicate.

Note:Position is calculated from the head/tail of the deque. The head/tail element has zero position.

Getting element value

Cbool Deque_GetHead (const struct Deque *deque, struct pair_t *data, size_t pos);
bool Deque_GetTail (const struct Deque *deque, struct pair_t *data, size_t pos);
C++bool Deque::GetHead (pair_t *data, size_t pos) const;
bool Deque::GetTail (pair_t *data, size_t pos) const;

Description: Get value of the element in selected position from the head/tail of the deque. The deque stay unchanged.

Access type: RO

Parameters:

  • deque - pointer to the deque
  • data - address where to return the value of the element
  • pos - element position in the deque from its head/tail

Return value:

  • TRUE (1) if element position is less than the deque size.
  • FALSE (0) if element with target position does not exist.

Note:Position is calculated from the head/tail of the deque. The head/tail element has zero position.

Changing elements order

These functions allow to change elements order in the deque and swap the elements.

Reversing elements order

Csize_t Deque_ReverseHead (struct Deque *deque, size_t pos, size_t count);
size_t Deque_ReverseTail (struct Deque *deque, size_t pos, size_t count);
C++size_t Deque::ReverseHead (size_t pos, size_t count);
size_t Deque::ReverseTail (size_t pos, size_t count);

Description: Reverse order of "count" elements in the deque starting from the "pos" position from the deque head/tail, and store them in the same place in new order. Other elements are not modified.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • pos - starting position from the head/tail of the deque
  • count - number of elements to reverse (-1 means all available elements)

Return value:

  • Real count of elements, which were reversed.
  • -1 if starting position is greater than or equal to the deque size, or functions are called from read only section, started by LockWritings access predicate.

Swapping elements

Cbool Deque_SwapHead (struct Deque *deque, size_t pos1, size_t pos2);
bool Deque_SwapTail (struct Deque *deque, size_t pos1, size_t pos2);
C++bool Deque::SwapHead (size_t pos1, size_t pos2);
bool Deque::SwapTail (size_t pos1, size_t pos2);

Description: Swap selected elements from the deque head/tail element.

Access type: RW

Parameters:

  • deque - pointer to the deque
  • pos1 - first element position in the deque from its head/tail
  • pos2 - second element position in the deque from its head/tail

Return value:

  • TRUE (1) if element positions are less than the deque size.
  • FALSE (0) if elements with target positions do not exist, or functions are called from read only section, started by LockWritings access predicate.

Minimum and maximum value

Next functions scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position, and return position of the first element, which has minimum/maximum key value. Returned position is relative position from the deque head/tail element, treating head/tail element as element with zero index.

Minimum value

Csize_t Deque_MinHead (const struct Deque *deque, struct pair_t *data, size_t pos, size_t count);
size_t Deque_MinTail (const struct Deque *deque, struct pair_t *data, size_t pos, size_t count);
C++size_t Deque::MinHead (pair_t *data, size_t pos, size_t count) const;
size_t Deque::MinTail (pair_t *data, size_t pos, size_t count) const;

Description: Scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position. Then return position of the first element, which has minimum value of the key, and store its value into the data structure is pointed by "data" pointer.

Access type: RO

Parameters:

  • deque - pointer to the deque
  • data - address where to return the value of the found element
  • pos - starting position from the head/tail of the deque
  • count - number of elements to check (-1 means all available elements)

Return value:

  • Index of the first element, having minimum value, in the deque, assuming that the head/tail element has zero index.
  • -1 if specified position is greater than or equal to the deque size.

Maximum value

Csize_t Deque_MaxHead (const struct Deque *deque, struct pair_t *data, size_t pos, size_t count);
size_t Deque_MaxTail (const struct Deque *deque, struct pair_t *data, size_t pos, size_t count);
C++size_t Deque::MaxHead (pair_t *data, size_t pos, size_t count) const;
size_t Deque::MaxTail (pair_t *data, size_t pos, size_t count) const;

Description: Scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position. Then return position of the first element, which has maximum value of the key, and store its value into the data structure is pointed by "data" pointer.

Access type: RO

Parameters:

  • deque - pointer to the deque
  • data - address where to return the value of the found element
  • pos - starting position from the head/tail of the deque
  • count - number of elements to check (-1 means all available elements)

Return value:

  • Index of the first element, having maximum value, in the deque, assuming that the head/tail element has zero index.
  • -1 if specified position is greater than or equal to the deque size.

Key searching

Following functions scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position, and return position of the first element, which is equal to the specified key or to the set of keys. Returned position is relative position from the deque head/tail element, treating head/tail element as element with zero index. If beginning position is greater than or equal to deque size, then -1 is returned.

Single key searching

Csize_t Deque_FindKeyHead (const struct Deque *deque, struct pair_t *data, union adt_t key, size_t pos, size_t count);
size_t Deque_FindKeyTail (const struct Deque *deque, struct pair_t *data, union adt_t key, size_t pos, size_t count);
C++size_t Deque::FindKeyHead (pair_t *data, adt_t key, size_t pos, size_t count) const;
size_t Deque::FindKeyTail (pair_t *data, adt_t key, size_t pos, size_t count) const;

Description: Scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position. Then return position of the first element, which is equal to the specified key, and store its value into the data structure is pointed by "data" pointer.

Access type: RO

Parameters:

  • deque - pointer to the deque
  • data - address where to return the value of the found element
  • key - key value to find in the deque
  • pos - starting position from the head/tail of the deque
  • count - number of elements to check (-1 means all available elements)

Return value:

  • Index of the first found element in the deque, assuming that the head/tail element has zero index.
  • -1 if no matches were met, or position is greater than or equal to the deque size.

Keys set searching

Csize_t Deque_FindKeysHead (const struct Deque *deque, struct pair_t *data, const union adt_t keys[], size_t size, size_t pos, size_t count);
size_t Deque_FindKeysTail (const struct Deque *deque, struct pair_t *data, const union adt_t keys[], size_t size, size_t pos, size_t count);
C++size_t Deque::FindKeysHead (pair_t *data, const adt_t keys[], size_t size, size_t pos, size_t count) const;
size_t Deque::FindKeysTail (pair_t *data, const adt_t keys[], size_t size, size_t pos, size_t count) const;

Description: Scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position. Then return position of the first element, which is equal to any key in the set of keys, and store its value into the data structure is pointed by "data" pointer.

Access type: RO

Parameters:

  • deque - pointer to the deque
  • data - address where to return the value of the found element
  • keys - array of keys to find in the deque
  • size - size of array of keys
  • pos - starting position from the head/tail of the deque
  • count - number of elements to check (-1 means all available elements)

Return value:

  • Index of the first found element in the deque, assuming that the head/tail element has zero index.
  • -1 if no matches were met, or position is greater than or equal to the deque size.

Searching for differences

Csize_t Deque_FindDiffHead (const struct Deque *deque, struct pair_t *data, size_t tpos, const struct Deque *source, size_t spos, size_t count);
size_t Deque_FindDiffTail (const struct Deque *deque, struct pair_t *data, size_t tpos, const struct Deque *source, size_t spos, size_t count);
C++size_t Deque::FindDiffHead (pair_t *data, size_t tpos, const Deque *source, size_t spos, size_t count) const;
size_t Deque::FindDiffTail (pair_t *data, size_t tpos, const Deque *source, size_t spos, size_t count) const;

Description: Compare "count" elements of two deque objects (key by key) from head/tail element to tail/head element, and return position and value of the first non equal element in target deque. Target deque is scanned from "tpos" position after its head/tail. And source deque is scanned from "spos" position after its head/tail. These functions do not compare assigned data fields, but only the keys. If no different keys were found during "count" elements, then functions return -1 and do not change data structure, which is pointed by "data" pointer.

Access type: RO

Parameters:

  • deque - pointer to target deque
  • data - address where to return the value of non equal element
  • tpos - starting position from the head/tail of target deque
  • source - pointer to source deque
  • spos - starting position from the head/tail of source deque
  • count - number of elements to check (-1 means all available elements)

Return value:

  • Index of the first non equal element in target deque, assuming that the head/tail element has zero index.
  • -1 if no different keys were found during "count" elements, or position is greater than or equal to target/source deque size.

Key counting

Following functions scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position, and return count of matches to the key or to the set of keys.

Single key counting

Csize_t Deque_CountKeyHead (const struct Deque *deque, union adt_t key, size_t pos, size_t count);
size_t Deque_CountKeyTail (const struct Deque *deque, union adt_t key, size_t pos, size_t count);
C++size_t Deque::CountKeyHead (adt_t key, size_t pos, size_t count) const;
size_t Deque::CountKeyTail (adt_t key, size_t pos, size_t count) const;

Description: Scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position. Then return count of the elements, which are equal to the specified key.

Access type: RO

Parameters:

  • deque - pointer to the deque
  • key - key value to find in the deque
  • pos - starting position from the head/tail of the deque
  • count - number of elements to check (-1 means all available elements)

Return value: Count of the elements, which are equal to the specified key.

Keys set counting

Csize_t Deque_CountKeysHead (const struct Deque *deque, const union adt_t keys[], size_t size, size_t pos, size_t count);
size_t Deque_CountKeysTail (const struct Deque *deque, const union adt_t keys[], size_t size, size_t pos, size_t count);
C++size_t Deque::CountKeysHead (const adt_t keys[], size_t size, size_t pos, size_t count) const;
size_t Deque::CountKeysTail (const adt_t keys[], size_t size, size_t pos, size_t count) const;

Description: Scan "count" elements in the deque from head/tail element to tail/head element, starting from "pos" position. Then return count of the elements, which are equal to any key in the set of keys.

Access type: RO

Parameters:

  • deque - pointer to the deque
  • keys - array of keys to find in the deque
  • size - size of array of keys
  • pos - starting position from the head/tail of the deque
  • count - number of elements to check (-1 means all available elements)

Return value: Count of the elements, which are equal to any key in the set of keys.

Comparison of deques

Csint64_t Deque_Compare (const struct Deque *deque, const struct Deque *source);
C++sint64_t Deque::Compare (const Deque *source) const;

Description: Compare two deque objects (key by key) starting from head/tail element to tail/head element, and return relations between them (less, equal or greater). These functions do not compare assigned data fields, but only the keys.

Access type: RO

Parameters:

  • deque - pointer to target deque
  • source - pointer to source deque

Return value:

  • -1 if first deque is less than second deque.
  • 0 if first deque is equal to second deque.
  • +1 if first deque is greater than second deque.

Check for equality

Cbool Deque_IsEqual (const struct Deque *deque, const struct Deque *source);
C++bool Deque::IsEqual (const Deque *source) const;

Description: Check if both deques have the same size, keys order and key values. These functions do not compare assigned data fields, but only the keys.

Access type: RO

Parameters:

  • deque - pointer to target deque
  • source - pointer to source deque

Return value:

  • TRUE (1) if deques are equal.
  • FALSE (0) if deques are not equal.

Deque properties

Deque built-in key type

Csize_t Deque_KeyType (const struct Deque *deque);
C++size_t Deque::KeyType (void) const;

Description: Return built-in key type and built-in key compare function, is assigned to this type, which internally used by the deque.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value: Built-in key type and corresponding built-in key compare function. Full list of such types is defined in built-in key types table.

Deque key compare function

CKeyCmp Deque_CompareFunction (const struct Deque *deque);
C++KeyCmp Deque::CompareFunction (void) const;

Description: Return pointer to key compare function is used by the deque.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value: Pointer to key compare function, which conforms to this prototype.

Deque pair copy function

CCopyFunc Deque_CopyFunction (const struct Deque *deque);
C++CopyFunc Deque::CopyFunction (void) const;

Description: Return pointer to copy function for element fields: key and data, is used by the deque.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value: Pointer to copy function for element fields, which conforms to this prototype.

Deque pair delete function

CDelFunc Deque_DeleteFunction (const struct Deque *deque);
C++DelFunc Deque::DeleteFunction (void) const;

Description: Return pointer to delete function to call for removing elements, which is used by the deque.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value: Pointer to delete function to call for removing elements, which conforms to this prototype.

Deque user's data

Cvoid* Deque_UserData (const struct Deque *deque);
C++void* Deque::UserData (void) const;

Description: Return pointer to user's data, required by element copy and delete functions, are used by the deque.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value: Pointer to user's data, required by element copy and delete functions.

Deque capacity

Csize_t Deque_Capacity (const struct Deque *deque);
C++size_t Deque::Capacity (void) const;

Description: Return the deque capacity.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value: Max count of objects that deque can hold.

Deque size

Csize_t Deque_Size (const struct Deque *deque);
C++size_t Deque::Size (void) const;

Description: Return current size of the deque (count of allocated objects).

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value: Count of allocated objects inside the deque.

Check if deque is empty

Cbool Deque_IsEmpty (const struct Deque *deque);
C++bool Deque::IsEmpty (void) const;

Description: Check if the deque is empty.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value:

  • TRUE (1) if deque is empty.
  • FALSE (0) if deque is not empty.

Check if deque is initialized

Cbool Deque_IsInit (const struct Deque *deque);
C++bool Deque::IsInit (void) const;

Description: Check if the deque is initialized.

Access type: RO

Parameters:

  • deque - pointer to the deque

Return value:

  • TRUE (1) if deque is initialized.
  • FALSE (0) if deque is not initialized.
Copyright 2012-2018 Jack Black. All rights reserved.