VecCapacity
Description
Capacity in elements: the most the vector can hold before the next reallocation. Always >= VecLen(v).
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in | Vector to query. |
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Vec.Init.c:53:
// Check initial state
bool result =
(VecLen(&vec) == 0 && VecCapacity(&vec) == 0 && VecBegin(&vec) == NULL && vec.allocator->alignment == 1 &&
vec.copy_init == NULL && vec.copy_deinit == NULL);- In
Vec.Init.c:65:
// Check initial state
result =
result && (VecLen(&test_vec) == 0 && VecCapacity(&test_vec) == 0 && VecBegin(&test_vec) == NULL &&
test_vec.allocator->alignment == 1 && test_vec.copy_init == NULL && test_vec.copy_deinit == NULL);- In
Vec.Init.c:87:
// Check initial state
bool result =
(VecLen(&vec) == 0 && VecCapacity(&vec) == 0 && VecBegin(&vec) == NULL && vec.allocator->alignment == 4 &&
vec.copy_init == NULL && vec.copy_deinit == NULL);- In
Vec.Init.c:99:
// Check initial state
result =
result && (VecLen(&test_vec) == 0 && VecCapacity(&test_vec) == 0 && VecBegin(&test_vec) == NULL &&
test_vec.allocator->alignment == 16 && test_vec.copy_init == NULL && test_vec.copy_deinit == NULL);- In
Vec.Init.c:120:
// Check initial state
bool result =
(VecLen(&vec) == 0 && VecCapacity(&vec) == 0 && VecBegin(&vec) == NULL && vec.allocator->alignment == 1 &&
vec.copy_init == (GenericCopyInit)TestItemCopyInit && vec.copy_deinit == (GenericCopyDeinit)TestItemDeinit);- In
Vec.Init.c:141:
// Check initial state
bool result =
(VecLen(&vec) == 0 && VecCapacity(&vec) == 0 && VecBegin(&vec) == NULL && vec.allocator->alignment == 8 &&
vec.copy_init == (GenericCopyInit)TestItemCopyInit && vec.copy_deinit == (GenericCopyDeinit)TestItemDeinit);- In
Vec.Init.c:221:
// Check initial state
if (VecLen(&vec) != 0 || VecCapacity(&vec) != 10 || VecBegin(&vec) == NULL || vec.allocator->alignment != 1 ||
vec.copy_init != NULL || vec.copy_deinit != NULL) {
result = false;- In
Vec.Init.c:240:
// After the scope, vec should be zeroed out
if (VecBegin(&vec) != NULL || VecLen(&vec) != 0 || VecCapacity(&vec) != 0) {
result = false;
}- In
Vec.Init.c:252:
// Check initial state
if (VecLen(&test_vec) != 0 || VecCapacity(&test_vec) != 5 || VecBegin(&test_vec) == NULL ||
test_vec.allocator->alignment != 1 || test_vec.copy_init != NULL || test_vec.copy_deinit != NULL) {
result = false;- In
Vec.Init.c:272:
// After the scope, test_vec should be zeroed out
if (VecBegin(&test_vec) != NULL || VecLen(&test_vec) != 0 || VecCapacity(&test_vec) != 0) {
result = false;
}- In
Vec.Init.c:300:
// Check that the clone has the same data but different memory
bool result =
(VecLen(&clone) == VecLen(&src) && VecCapacity(&clone) >= VecLen(&src) && VecBegin(&clone) != VecBegin(&src) &&
clone.allocator->alignment == src.allocator->alignment);- In
Vec.Memory.c:35:
// Original capacity should be at least 100
bool result = (VecCapacity(&vec) >= 100);
// Try to reduce space
- In
Vec.Memory.c:41:
// Capacity should now be closer to the actual length
result = result && (VecCapacity(&vec) < 100) && (VecCapacity(&vec) >= VecLen(&vec));
// Check that the data is still intact
- In
Vec.Memory.c:114:
// Initial capacity should be 0
bool result = (VecCapacity(&vec) == 0);
// Reserve space for 50 elements
- In
Vec.Memory.c:120:
// Capacity should now be at least 50
result = result && (VecCapacity(&vec) >= 50);
// Length should still be 0
- In
Vec.Memory.c:132:
// Capacity should still be at least 50
result = result && (VecCapacity(&vec) >= 50);
// Length should now be 5
- In
Vec.Memory.c:141:
// Capacity should still be at least 50
result = result && (VecCapacity(&vec) >= 50);
// Clean up
- In
Vec.Memory.c:170:
// Remember the capacity
size original_capacity = VecCapacity(&vec);
// Clear the vector
- In
Vec.Memory.c:179:
// Capacity should remain the same
result = result && (VecCapacity(&vec) == original_capacity);
// Data pointer should still be valid
- In
Graph.Init.c:21:
ValidateGraph(&graph);
bool result = VecCapacity(&graph.slots) >= 8;
GraphNodeId first_id = GraphAddNodeR(&graph, 10);
GraphNodeId second_id = GraphAddNodeR(&graph, 20);- In
Graph.Init.c:26:
GraphNodeId third_id = GraphAddNodeR(&graph, 30);
u64 slot_count = VecLen(&graph.slots);
size slot_capacity = VecCapacity(&graph.slots);
u32 first_generation = GraphNodeIdGeneration(first_id);
u32 second_generation = GraphNodeIdGeneration(second_id);- In
Graph.Init.c:46:
result = result && !GraphContainsNode(&graph, third_id);
result = result && VecLen(&graph.slots) == slot_count && VecLen(&graph.free_indices) == slot_count;
result = result && VecCapacity(&graph.slots) == slot_capacity && VecCapacity(&graph.free_indices) >= slot_count;
result = result && graph.pending_delete_count == 0 && VecLen(&graph.pending_edge_removals) == 0;- In
Vec.Type.c:31:
// Check initial state
bool result =
(VecLen(&vec) == 0 && VecCapacity(&vec) == 0 && VecBegin(&vec) == NULL && vec.allocator->alignment == 1 &&
vec.copy_init == NULL && vec.copy_deinit == NULL);- In
Vec.Type.c:43:
// Check initial state
result =
result && (VecLen(&test_vec) == 0 && VecCapacity(&test_vec) == 0 && VecBegin(&test_vec) == NULL &&
test_vec.allocator->alignment == 1 && test_vec.copy_init == NULL && test_vec.copy_deinit == NULL); // Check initial state
bool result =
(VecLen(&vec) == 0 && VecCapacity(&vec) == 0 && VecBegin(&vec) == NULL &&
vec.copy_init == (GenericCopyInit)ComplexItemCopyInit &&
vec.copy_deinit == (GenericCopyDeinit)ComplexItemDeinit); // Reserve zero capacity
VecReserve(&vec, 0);
result = result && (VecCapacity(&vec) == 0);
// Push an element (should auto-resize)
- In
Access.h:36:
/// TAGS: Str, Access, Capacity
///
#define StrCapacity(str) VecCapacity(str)
///
Last updated on