Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
vector.h
Go to the documentation of this file.
1 /* *************************************************************************************
2  Copyright (c) 2021, Lowell D. Thomas
3  All rights reserved.
4 
5  This file is part of APG Version 7.0.
6  APG Version 7.0 may be used under the terms of the BSD 2-Clause License.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 
14  2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 * *************************************************************************************/
30 #ifndef LIB_VECTOR_H_
31 #define LIB_VECTOR_H_
32 
46 typedef struct {
61 } vec_stats;
62 
63 void* vpVecCtor(void* vpMem, aint uiElementSize, aint uiInitialAlloc);
64 void vVecDtor(void* vpCtx);
65 abool bVecValidate(void* vpCtx);
66 void* vpVecPush(void* vpVec, void* vpElement);
67 void* vpVecPushn(void* vpCtx, void* vpElement, aint uiCount);
68 void* vpVecPop(void* vpCtx);
69 void* vpVecPopn(void* vpCtx, aint uiCount);
70 void* vpVecPopi(void* vpCtx, aint uiIndex);
71 void* vpVecFirst(void* vpCtx);
72 void* vpVecLast(void* vpCtx);
73 void* vpVecAt(void* vpCtx, aint uiIndex);
74 aint uiVecLen(void* vpCtx);
75 void* vpVecBuffer(void* vpCtx);
76 void vVecClear(void* vpCtx);
77 void vVecStats(void* vpCtx, vec_stats* spStats);
78 
79 #endif /* LIB_VECTOR_H_ */
vec_stats::uiReserved
aint uiReserved
The current number of elements reserved.
Definition: vector.h:50
bVecValidate
abool bVecValidate(void *vpCtx)
Validates a vector component context.
Definition: vector.c:179
vpVecPopn
void * vpVecPopn(void *vpCtx, aint uiCount)
Pops one or more elements from the end of the array.
Definition: vector.c:271
vec_stats::uiGrownCount
aint uiGrownCount
The number times the vector was automatically extended.
Definition: vector.h:58
vVecDtor
void vVecDtor(void *vpCtx)
The vector component destructor.
Definition: vector.c:161
vpVecPushn
void * vpVecPushn(void *vpCtx, void *vpElement, aint uiCount)
Adds one or more elements to the end of the array.
Definition: vector.c:221
uiVecLen
aint uiVecLen(void *vpCtx)
Get the vector length. That is, the number of elements on the vector.
Definition: vector.c:385
vpVecCtor
void * vpVecCtor(void *vpMem, aint uiElementSize, aint uiInitialAlloc)
The vector object constructor.
Definition: vector.c:118
vec_stats::uiGrownBytes
aint uiGrownBytes
The number of bytes automatically added to the vector.
Definition: vector.h:60
vec_stats::uiOriginalBytes
aint uiOriginalBytes
The initial number of bytes allocated to the vector.
Definition: vector.h:49
vpVecPop
void * vpVecPop(void *vpCtx)
Pops one element from the end of the array.
Definition: vector.c:250
vec_stats::uiUsed
aint uiUsed
The current number elements used.
Definition: vector.h:51
vpVecPopi
void * vpVecPopi(void *vpCtx, aint uiIndex)
Pops the element at the given zero-based index and all higher indexes.
Definition: vector.c:306
vec_stats
Vector usage statistics.
Definition: vector.h:46
vec_stats::uiPushed
aint uiPushed
The total number of elements pushed onto (added to) the vector.
Definition: vector.h:56
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
vec_stats::uiOriginalElements
aint uiOriginalElements
The initial number of elements allocated to the vector.
Definition: vector.h:48
vec_stats::uiUsedBytes
aint uiUsedBytes
The current number of bytes in use.
Definition: vector.h:54
vpVecLast
void * vpVecLast(void *vpCtx)
Get the last element one the vector. The vector is not altered.
Definition: vector.c:343
vec_stats::uiReservedBytes
aint uiReservedBytes
The current number of bytes reserved.
Definition: vector.h:53
vpVecBuffer
void * vpVecBuffer(void *vpCtx)
Get a pointer to the vector buffer.
Definition: vector.c:402
vpVecFirst
void * vpVecFirst(void *vpCtx)
Get the first element one the vector. The vector is not altered.
Definition: vector.c:326
vpVecAt
void * vpVecAt(void *vpCtx, aint uiIndex)
Get a the indexed vector element. The vector is not altered.
Definition: vector.c:362
vpVecPush
void * vpVecPush(void *vpVec, void *vpElement)
Adds one element to the end of the array.
Definition: vector.c:193
vec_stats::uiPopped
aint uiPopped
The total number of elements popped from (removed from) the vector.
Definition: vector.h:57
vec_stats::uiGrownElements
aint uiGrownElements
The number new elements automatically added to the vector.
Definition: vector.h:59
abool
uint8_t abool
abool is the APG bool type.
Definition: apg.h:140
vVecClear
void vVecClear(void *vpCtx)
Clears all used elements in a vector component.
Definition: vector.c:420
vec_stats::uiMaxUsedBytes
aint uiMaxUsedBytes
The maximum number of bytes used over the lifetime of the vector.
Definition: vector.h:55
vVecStats
void vVecStats(void *vpCtx, vec_stats *spStats)
Definition: vector.c:459
vec_stats::uiElementSize
aint uiElementSize
The number of bytes in one element.
Definition: vector.h:47
vec_stats::uiMaxUsed
aint uiMaxUsed
The maximum number of elements used during the vector's lifetime.
Definition: vector.h:52
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.