Site Logo

maxdz Software GmbH

en | de
Home

Team

Products

mdz_ui

mdz_xml

mdz_string

mdz_vector

mdzWebSiteGenerator

mdzTennisTracker

Shop

Legals

Contacts

mdz_vector Overview and Reference

mdz_vector - very lightweight, versatile and speedy C vector library. Source code of library is highly-portable, conforms to ANSI C 89/90 Standard. Builds for Win32/Win64, Linux, FreeBSD, Android, macOS are available.

Please refer to mdz_vector Wiki for API details.

mdz_vector Advantages

1. Very high portability: the whole code conforms to ANSI C 89/90 Standard. Multithreading/asynchronous part is POSIX compatible (under UNIX/Linux).

2. Very little dependencies: basically, mdz_vector functions are only dependent on standard C-library memory-management/access functions. Multithreading part is dependent on POSIX pthreads API (under UNIX/Linux) and old process control/synchronization API (from Windows 2000). It means you can use library in your code without any further dependencies except standard platform libraries/APIs.

3. Very fast: comparison tables are coming soon...

4. Flexibilty: nearly all functions contain not only "left position" but also "right position" parameters to limit processed area from right. Vector contains more functions than according STL, boost or glib analogs have.

5. Extended error-checking: all functions preserve internal error-code pointing the problem. It is possible to use strict error-checking (when all preserved error-codes should be MDZ_ERROR_NONE) or "relaxed"-checking - when only returned mdz_false will indicate error.

6. Extended control: vector does only explicit operations. It means for example, when "insert" function is called - it will return error if there is not enough capacity in vector. No implicit reservations will be made.

7. Attached usage: vector should not necessarily use dynamically-allocated memory - which may be not available on your embedded system (or if malloc()/free() are forbidden to use in you safety-critical software). Just attach vector/data to your statically-allocated memory and use all vector functionality.

8. Asynchronous execution: almost all functions can be executed asynchronously.


mdz_vector API Reference

Asynchronous execution

Many functions of mdz_vector accept parameters for asynchronous execution.
The only relevant parameter is:

- struct mdz_asyncData* pAsyncData - pointer to shared async data for asynchronous call, or NULL if call should be synchronous

Fields of struct mdz_asyncData* are following:

TypeParameterDescription
void* m_pStringPointer to string instance
mdz_bool m_bFinishedmdz_true if the call is completely finished. Otherwise mdz_false (if interrupted/cancelled)
size_t m_nResultResult of call. Invalid if call is not completely finished (m_bFinished is mdz_false)
void* m_pDataAdditional data returned by call (if any). Invalid if call is not completely finished (m_bFinished is mdz_false)
mdz_bool m_bCancelShould be set by client in mdz_true during call execution, to cancel the call. Otherwise mdz_false
pthread_t / HANDLE m_hThreadHandle to thread on which the call is executed. May be used by client for wait operations


mdz_vector API Reference is generated using mdzApiRefGenerator.

mdz_vector General Information and Functions

mdz_vector is dynamically-sized contiguous container.

Capacity - how many items memory is reserved for.
Size - how many items are actually residing in a vector.

"reserve/AndReserve" functions allocate/reallocate memory dynamically using malloc()/realloc().
"attach" functionality allows attaching contiguous block of memory to vector, for using vector functions on it.

Library init functions:

mdz_vector_init
mdz_vector_init_attached
mdz_vector_uninit
mdz_vector_create
mdz_vector_create_attached
mdz_vector_destroy
mdz_vector_clear
mdz_vector_attachData

Reserve capacity functions:

mdz_vector_reserve
mdz_vector_reserveAndInit
mdz_vector_capacity
mdz_vector_size
mdz_vector_resize
mdz_vector_offsetFromStart
mdz_vector_isAttachedData

Insert/remove functions:

mdz_vector_insert
mdz_vector_append
mdz_vector_removeFrom
mdz_vector_remove
mdz_vector_trimLeft
mdz_vector_trimRight
mdz_vector_trim

Find functions:

mdz_vector_findSingle
mdz_vector_find
mdz_vector_firstOf
mdz_vector_firstNotOf
mdz_vector_rfindSingle
mdz_vector_rfind
mdz_vector_lastOf
mdz_vector_lastNotOf

Miscellaneous functions:

mdz_vector_compare
mdz_vector_replace
mdz_vector_count
mdz_vector_copySubVector
mdz_vector_copySubVectorFrom


mdz_vector_init

Initializes vector library. This function should be called before any other function of the library.

mdz_bool mdz_vector_init(const uint32_t* pFirstNameHash, const uint32_t* pLastNameHash, const uint32_t* pEmailHash, const uint32_t* pLicenseHash);

ParameterDescription
pFirstNameHashuser first name hash code
pLastNameHashuser last name hash code
pEmailHashuser e-mail hash code
pLicenseHashlicense hash code

ReturnDescription
mdz_trueif the initialization has succeed, otherwise false

mdz_vector Reference

mdz_vector_init_attached

Initializes vector library. This function should be caled before any other function of the library.
Memory for license data starts at position pStart. Size of internal initialization structure is returned in pSize.

mdz_bool mdz_vector_init_attached(const uint32_t* pFirstNameHash, const uint32_t* pLastNameHash, const uint32_t* pEmailHash, const uint32_t* pLicenseHash, const char* pStart, size_t nAreaSize, size_t* pOutSize);

ParameterDescription
pFirstNameHashuser first name hash code
pLastNameHashuser last name hash code
pEmailHashuser e-mail hash code
pLicenseHashlicense hash code
pStartmemory start position of license data
nAreaSizesize of available memory from pStart in bytes. Should be large enough for license data (> 500 bytes)
pOutSizeactual size of placed license data in bytes

ReturnDescription
mdz_trueif the initialization has succeed, otherwise false

mdz_vector Reference

mdz_vector_uninit

Un-initializes vector library and frees corresponding memory allocations.

void mdz_vector_uninit(void);

mdz_vector Reference

mdz_vector_create

Create empty vector with Capacity and Size 0. Memory for vector structure is allocated using malloc().

struct mdz_Vector* mdz_vector_create(size_t nTypeSize);

ParameterDescription
nTypeSizesizeof of type used in vector. Allowed nTypeSize are 1, 2, 4 or 8

ReturnDescription
NULLif library is not initialized with mdz_containers_init() call
NULLif not allowed nTypeSize is used
NULLif memory allocation failed
Resultpointer to vector for use in other mdz_vector functions

mdz_vector Reference

mdz_vector_create_attached

Create empty vector with Capacity and Size 0. Memory for vector structure starts at position pStart. Size in bytes of internal vector structure (it is usually bigger than mdz_Vector!) is returned in pSize.

struct mdz_Vector* mdz_vector_create_attached(size_t nTypeSize, const void* pStart, size_t* pSize);

ParameterDescription
nTypeSizesizeof of type used in vector. Allowed nTypeSize are 1, 2, 4 or 8
pStartmemory start position of vector structure
pSizeinitially should contain size of available memory from pStart. After vector creation - contains actual size of internal vector structure

ReturnDescription
NULLif library is not initialized with mdz_containers_init() call
NULLif not allowed nTypeSize is used
NULLif pStart == NULL or pSize == NULL
NULLif size in pSize is smaller than size of internal vector structure
Resultpointer to vector for use in other mdz_vector functions. Normally it equals to pStart

mdz_vector Reference

mdz_vector_destroy

Destroy vector including underlying data using free().
If vector is attached using mdz_vector_create_attached(), vector controlling data will not be destroyed.
If vector data is attached using mdz_vector_attachData(), m_pData will not be destroyed.

void mdz_vector_destroy(const struct mdz_Vector* pVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()

mdz_vector Reference

mdz_vector_clear

Clear m_pData of vector with setting Size in 0.

void mdz_vector_clear(struct mdz_Vector* pVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create()

mdz_vector Reference

mdz_vector_attachData

Attach pre-allocated data to vector, assigning pData to m_pData. If attached, m_pData will not be destroyed in mdz_vector_destroy()

mdz_bool mdz_vector_attachData(struct mdz_Vector* pVector, void* pData, size_t nOffsetFromStart, size_t nCapacity, enum mdz_attach_type enAttachType);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
pDatapointer to pre-allocated data to attach
nOffsetFromStartposition in pre-allocated data to attach from. Can be > 0
nCapacityfull capacity pre-allocated data in items
enAttachTypetype of attachment. Only MDZ_ATTACH_ZEROSIZE and MDZ_ATTACH_SIZE_NO_TERMINATOR are allowed

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif pData == NULL (MDZ_ERROR_DATA), or nOffsetFromStart >= nCapacity (MDZ_ERROR_OFFSET), or invalid enAttachType (MDZ_ERROR_ATTACHTYPE)
mdz_trueoperation succeeded

mdz_vector Reference

mdz_vector_reserve

Reserve nNewCapacity items for vector. Vector Size does not change. Reservation is not made if m_pData is attached using mdz_vector_attachData()

mdz_bool mdz_vector_reserve(struct mdz_Vector* pVector, size_t nNewCapacity);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nNewCapacitynew capacity in items to reserve

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif m_pData is attached using mdz_vector_attachData() (MDZ_ERROR_ATTACHED)
mdz_true reservation succeeded, or nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY)

mdz_vector Reference

mdz_vector_reserveAndInit

Reserve nNewCapacity items for vector and initializes all items in pItem. May be called only on empty vectors (with Size == 0). After call, vector Size equals to Capacity.
Reservation is not made if m_pData is attached using mdz_vector_attachData() and nNewCapacity > Capacity

mdz_bool mdz_vector_reserveAndInit(struct mdz_Vector* pVector, size_t nNewCapacity, const void* pItem);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nNewCapacitycapacity to reserve in items
pItemitem for vector initialization. If NULL, 0 will be used for initialization

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif Size > 0 (MDZ_ERROR_NONEMPTY)
mdz_falseif m_pData is attached using mdz_vector_attachData() (MDZ_ERROR_ATTACHED)
mdz_trueif nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY), initialization succeeded
mdz_truereservation and initialization succeeded

mdz_vector Reference

mdz_vector_capacity

Return vector Capacity in items.

size_t mdz_vector_capacity(const struct mdz_Vector* pVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()

ReturnDescription
SIZE_MAXif pVector == NULL
Capacityotherwise

mdz_vector Reference

mdz_vector_size

Return vector Size in items.

size_t mdz_vector_size(const struct mdz_Vector* pVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeotherwise

mdz_vector Reference

mdz_vector_resize

Set vector Size. Size must be <= Capacity.

mdz_bool mdz_vector_resize(struct mdz_Vector* pVector, size_t nNewSize);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nNewSizenew Size to set vector in

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif nNewSize > Capacity (MDZ_ERROR_CAPACITY). Vector Size is not changed
mdz_trueif succeeded

mdz_vector Reference

mdz_vector_offsetFromStart

Return vector OffsetFromStart in items.

size_t mdz_vector_offsetFromStart(const struct mdz_Vector* pVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()

ReturnDescription
SIZE_MAXif pVector == NULL
OffsetFromStartotherwise

mdz_vector Reference

mdz_vector_isAttachedData

Return if vector data is attached.

mdz_bool mdz_vector_isAttachedData(const struct mdz_Vector* pVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif vector data is not attached
mdz_trueif vector data is attached

mdz_vector Reference

mdz_vector_insert

Insert nCount items in vector. Capacity should contain enough free space for nCount items. Vector m_pData and pItems cannot overlap. Size grows on nCount.

mdz_bool mdz_vector_insert(struct mdz_Vector* pVector, size_t nLeftPos, const void* pItems, size_t nCount, mdz_bool bReserve);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based position to insert. If nLeftPos == Size or -1, items are appended. nLeftPos > Size is not allowed
pItemsitems to insert. If NULL, 0 will be used for insertion nCount times
nCountnumber of items to insert
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data but m_pData is attached using mdz_vector_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the vector (MDZ_ERROR_CAPACITY)
mdz_trueif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Size (MDZ_ERROR_BIGLEFT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No insertion is made
mdz_trueinsertion succeeded

mdz_vector Reference

mdz_vector_append

Appends nCount items in vector. Capacity should contain enough free space for nCount items. Vector m_pData and pItems cannot overlap. Size grows on nCount.

mdz_bool mdz_vector_append(struct mdz_Vector* pVector, const void* pItems, size_t nCount, mdz_bool bReserve);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
pItemsitems to insert. If NULL, 0 will be used for insertion nCount times
nCountnumber of items to insert
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data but m_pData is attached using mdz_vector_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the vector (MDZ_ERROR_CAPACITY)
mdz_trueif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No insertion is made
mdz_trueinsertion succeeded

mdz_vector Reference

mdz_vector_findSingle

Find first occurrence of pItem in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_findSingle(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItem);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of vector
nRightPos0-based end position to search up to. Use Size-1 to search till the end of vector
pItempointer to item to find. If NULL, value type of NULL (normally 0) nCount times, will be used for search

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_vector Reference

mdz_vector_find

Find first occurrence of pItems in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_find(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount, enum mdz_find_method enFindMethod);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of vector
nRightPos0-based end position to search up to. Use Size-1 to search till the end of vector
pItemspointer to items to find. If NULL, value type of NULL (normally 0) nCount times, will be used for search
nCountnumber of items to find
enFindMethodfind method to use. See details in mdz_find_method description

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_vector Reference

mdz_vector_firstOf

Find first occurrence of any item of pItems in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_firstOf(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of vector
nRightPos0-based end position to search up to. Use Size-1 to search till the end of vector
pItemspointer to items to find. If NULL, 0 will be used for search
nCountnumber of items to find. 1 if pItems == NULL

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_vector Reference

mdz_vector_firstNotOf

Find first non-occurrence of any item of pItems in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_firstNotOf(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of vector
nRightPos0-based end position to search up to. Use Size-1 to search till the end of vector
pItemspointer to items to check. If NULL, 0 will be used for search
nCountnumber of items to check. 1 if pItems == NULL

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif non-occurrence is not found
Result0-based position of first non-occurrence

mdz_vector Reference

mdz_vector_rfindSingle

Find last occurrence of pItem in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_rfindSingle(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItem);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based end position to find up to. Use 0 to search till the beginning of vector
nRightPos0-based start position to find from right. Use Size-1 to search from the end of vector
pItempointer to items to find. If NULL, value type of NULL (normally 0) nCount times, will be used for search

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGCOUNT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_vector Reference

mdz_vector_rfind

Find last occurrence of pItems in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_rfind(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount, enum mdz_find_method enFindMethod);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based end position to find up to. Use 0 to search till the beginning of vector
nRightPos0-based start position to find from right. Use Size-1 to search from the end of vector
pItemspointer to items to find. If NULL, value type of NULL (normally 0) nCount times, will be used for search
nCountnumber of items to find
enFindMethodfind method to use. See details in mdz_find_method description

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_vector Reference

mdz_vector_lastOf

Find last occurrence of any item of pItems in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_lastOf(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based end position to search up to. Use 0 to search till the beginning of vector
nRightPos0-based start position to search from right. Use Size-1 to search from the end of vector
pItemspointer to items to find. If NULL, value type of NULL (normally 0) will be used for search
nCountnumber of items to find

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_vector Reference

mdz_vector_lastNotOf

Find last non-occurrence of any item of pItems in vector. Returns 0-based position of match (if found), or vector Size if not found, or SIZE_MAX if error.

size_t mdz_vector_lastNotOf(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based end position to search up to. Use 0 to search till the beginning of vector
nRightPos0-based start position to search from right. Use Size-1 to search from the end of vector
pItemspointer to items to find. If NULL, value type of NULL (normally 0) will be used for search
nCountnumber of items to find

ReturnDescription
SIZE_MAXif pVector == NULL
Sizeif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif non-occurrence is not found
Result0-based position - position of first match

mdz_vector Reference

mdz_vector_removeFrom

Remove nCount item(s) starting from 0-based nLeftPos position. After the operation, Capacity doesn't change, Size decreases on nCount.

mdz_bool mdz_vector_removeFrom(struct mdz_Vector* pVector, size_t nLeftPos, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to remove item(s) from. Use 0 to remove from the beginning of vector
nCountnumber of item(s) to remove. Assure that nLeftPos + nCount - 1 < Size - otherwise no removes will be made

ReturnDescription
mdz_falseif pVector == NULL
mdz_trueif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGLEFT). No removes are made
mdz_trueoperation succeeded

mdz_vector Reference

mdz_vector_remove

Remove all occurrences of nCount item(s) matching to pItems, residing between nLeftPos and nRightPos. Vector m_pData and pItems cannot overlap. After remove(s) Capacity doesn't change, Size decreases on nCount of removed items.

mdz_bool mdz_vector_remove(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to remove item(s) from. Use 0 to search from the beginning of vector
nRightPos0-based end position to remove item(s) up to. Use Size-1 to search till the end of vector
pItemspointer to items to remove. If NULL, value type of NULL (normally 0) nCount times, will be used for search
nCountnumber of item(s) to remove

ReturnDescription
mdz_falseif pVector == NULL
mdz_trueif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No removes are made
mdz_trueoperation succeeded

mdz_vector Reference

mdz_vector_trimLeft

Remove items which are contained in pItems from left, until first non-contained in pItems item is reached. Vector m_pData and pItems cannot overlap.

mdz_bool mdz_vector_trimLeft(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to trim item(s) from left. Use 0 to trim from the beginning of vector
nRightPos0-based end position to trim item(s) up to. Use Size-1 to trim till the end of vector
pItemspointer to items to remove. If NULL, value type of NULL (normally 0) will be used
nCountnumber of items to remove. If pItems is NULL, nCount is set to 1

ReturnDescription
mdz_falseif pVector == NULL
mdz_trueif vector is empty (MDZ_ERROR_EMPTY), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No trims are made
mdz_trueoperation succeeded

mdz_vector Reference

mdz_vector_trimRight

Remove items which are contained in pItems from right, until first non-contained in pItems item is reached. Vector m_pData and pItems cannot overlap.

mdz_bool mdz_vector_trimRight(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based end position to trim item(s) up to. Use 0 to trim till the beginning of vector
nRightPos0-based start position to trim item(s) from right. Use Size-1 to trim from the end of vector
pItemspointer to items to remove. If NULL, value type of NULL (normally 0) will be used
nCountnumber of items to remove. If pItems is NULL, nCount is set to 1

ReturnDescription
mdz_falseif pVector == NULL
mdz_trueif vector is empty (MDZ_ERROR_EMPTY), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No removes are made
mdz_trueoperation succeeded

mdz_vector Reference

mdz_vector_trim

Remove items which are contained in pItems from left and from right, until first non-contained in pItems item is reached. Vector m_pData and pItems cannot overlap.

mdz_bool mdz_vector_trim(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to trim item(s) from left. Use 0 to trim from the beginning of vector
nRightPos0-based start position to trim item(s) from right. Use Size-1 to trim from the end of vector
pItemspointer to items to remove. If NULL, value type of NULL (normally 0) will be used
nCountnumber of items to remove. If pItems is NULL, nCount is set to 1

ReturnDescription
mdz_falseif pVector == NULL
mdz_trueif vector is empty (MDZ_ERROR_EMPTY), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No removes are made
mdz_trueoperation succeeded

mdz_vector Reference

mdz_vector_compare

Compare content of vector with pItems.

enum mdz_compare_result mdz_vector_compare(struct mdz_Vector* pVector, size_t nLeftPos, const void* pItems, size_t nCount);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to compare from. Use 0 to compare from the beginning of vector
pItemspointer to items to compare. If NULL, value type of NULL (normally 0) nCount times, will be used for comparison
nCountnumber of items to compare

ReturnDescription
MDZ_COMPARE_ERRORif pVector == NULL
MDZ_COMPARE_NONEQUALif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGLEFT). No comparison is made
MDZ_COMPARE_EQUAL or MDZ_COMPARE_NONEQUALResult of comparison

mdz_vector Reference

mdz_vector_replace

Replace every occurrence of pItemsBefore with pItemsAfter. There should be enough Capacity for replacing data. Vector m_pData and pItemsBefore/pItemsAfter cannot overlap.

mdz_bool mdz_vector_replace(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItemsBefore, size_t nCountBefore, const void* pItemsAfter, size_t nCountAfter, mdz_bool bReserve);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to search for replace from. Use 0 to search from the beginning of vector
nRightPos0-based end position to search for replace up to. Use Size-1 to search till the end of vector
pItemsBeforepointer to items to replace. If NULL, value type of NULL (normally 0) nCountBefore times, will be searched
nCountBeforenumber of items to replace
pItemsAfterpointer to items to replace with. If NULL, value type of NULL (normally 0) nCountAfter times, will be used to replace
nCountAfternumber of items to replace with
bReserveif mdz_true reserve capacity when there is not enough space for replacement, otherwise mdz_false

ReturnDescription
mdz_falseif pVector == NULL
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data but m_pData is attached using mdz_vector_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the vector (MDZ_ERROR_CAPACITY)
mdz_trueif nCountBefore == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCountBefore is too big (MDZ_ERROR_BIGCOUNT). No replacements is made
mdz_trueoperation succeeded

mdz_vector Reference

mdz_vector_count

Counts number of pItems subvector occurrences in vector.

size_t mdz_vector_count(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pItems, size_t nCount, mdz_bool bAllowOverlapped);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to count from. Use 0 to count from the beginning of vector
nRightPos0-based end position to count up to. Use Size-1 to count till the end of vector
pItemsitems/subvector to count. If NULL, value type of NULL (normally 0) nCount times, will be counted
nCountlength of subvector to count
bAllowOverlappedmdz_true if overlapped subvectors should be counted, otherwise mdz_false

ReturnDescription
SIZE_MAXif pVector == NULL
0if nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No counting is made
Result0-based count of subvector occurrences. 0 if not found

mdz_vector Reference

mdz_vector_copySubVector

Fills pSubVector with items, starting from nLeftPos and ending with one of pSeparators or nRightPos.

size_t mdz_vector_copySubVector(struct mdz_Vector* pVector, size_t nLeftPos, size_t nRightPos, const void* pSeparators, size_t nSeparatorsCount, struct mdz_Vector* pSubVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to get items from. Use 0 to start from the beginning of vector
nRightPos0-based end position to get items up to. Use Size-1 to proceed till the end of vector
pSeparatorsseparators to get items up to. If NULL, value type of NULL (normally 0) will be used
nSeparatorsCountnumber of separators
pSubVectorpointer to vector where items should be copied. Data in pSubVector will be re-reserved to appropriate size if necessary

ReturnDescription
SIZE_MAXif pVector == NULL, or pSubVector == NULL (MDZ_ERROR_SUBCONTAINER), or reallocation of m_pData in pSubVector was necessary but failed (MDZ_ERROR_ALLOCATION)
Sizeif nSeparatorsCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No copying is made
Result0-based position after separator if found, or Size if not found

mdz_vector Reference

mdz_vector_copySubVectorFrom

Fills pSubVector with items, starting from nLeftPos and containing nCount items.

size_t mdz_vector_copySubVectorFrom(struct mdz_Vector* pVector, size_t nLeftPos, size_t nCount, struct mdz_Vector* pSubVector);

ParameterDescription
pVectorpointer to vector returned by mdz_vector_create() or mdz_vector_create_attached()
nLeftPos0-based start position to get items from. Use 0 to start from the beginning of vector
nCountnumber of items to copy
pSubVectorpointer to vector where items should be copied. Data in pSubVector will be re-reserved to appropriate size if necessary

ReturnDescription
SIZE_MAXif pVector == NULL, or pSubVector == NULL (MDZ_ERROR_SUBCONTAINER), or reallocation of m_pData in pSubVector was necessary but failed (MDZ_ERROR_ALLOCATION)
Sizeif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGLEFT). No copying is made
Result0-based position after copied data

mdz_vector Reference
Software Development. Strive for the Impossible to achieve Excellence.
Copyright Ⓒ 2017 - 2024 maxdz Software GmbH. All rights reserved.
Site content is generated using mdzWebSiteGenerator