VecDeleteRangeFast
Description
Delete count elements starting at start using the fast (order-not-preserving) path.
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in,out | Vector handle. |
start |
in | First deleted index. |
count |
in | Number of elements to delete. |
Success
Returns to the caller. The vector length shrinks by count; [start, start + count) is populated by elements pulled from the tail (no defined order). When copy_deinit is configured it is invoked on each dropped element.
Failure
Function cannot fail. start + count exceeding length is a caller bug and aborts via LOG_FATAL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Remove.h:115:
/// TAGS: Str, Delete, Range, Fast, Unordered
///
#define StrDeleteRangeFast(str, start, count) VecDeleteRangeFast((str), (start), (count))
#ifdef __cplusplus- In
VecInt.c:257:
uint64_t len = VecLen(vec);
if (len > 0 && start < len && count > 0 && start + count <= len) {
VecDeleteRangeFast(vec, start, count);
}
break;- In
VecCharPtr.c:297:
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
size_t count = extract_u32(data, offset, data_size) % (VecLen(vec) - index + 1);
VecDeleteRangeFast(vec, index, count);
}
break;- In
VecStr.c:303:
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
size_t count = extract_u32(data, offset, data_size) % (VecLen(vec) - index + 1);
VecDeleteRangeFast(vec, index, count);
}
break;- In
Complex.c:566:
// Test VecDeleteRangeFast (fast delete range)
VecDeleteRangeFast(&vec, 0, 2); // Delete 10 and 20
// Check vector length after fast range deletion
- In
Remove.c:335:
// Test VecDeleteRangeFast
bool test_vec_delete_range_fast(void) {
WriteFmtLn("Testing VecDeleteRangeFast");
// Create a vector of integers
- In
Remove.c:367:
}
VecDeleteRangeFast(&vec, start_index, count);
// Print after state
- In
Remove.c:786:
int fast_start = 2;
int fast_count = 3;
VecDeleteRangeFast(&vec, fast_start, fast_count);
// Print after state
- In
Remove.c:863:
// Test R-value fast delete range operation
VecDeleteRangeFast(&vec, 2, 3);
// Print after state
- In
Remove.c:930:
// start + count == length: valid, removes everything.
VecDeleteRangeFast(&vec, 0, 3);
bool result = (VecLen(&vec) == 0);- In
Remove.c:997:
// NULL out-ptr -> copy_deinit invoked on each removed element.
VecDeleteRangeFast(&vec, 0, 3);
bool result = (g_deinit_count == 3);- In
Remove.c:1019:
}
VecDeleteRangeFast(&vec, 0, 3);
bool result = (g_deinit_count == 3);- In
Remove.c:1042:
}
VecDeleteRangeFast(&vec, 0, 2);
bool result = (g_deinit_count == 2);- In
Remove.c:1064:
}
VecDeleteRangeFast(&vec, 0, 3);
bool result = (g_deinit_count == 3);- In
Remove.c:1088:
}
VecDeleteRangeFast(&vec, 0, 3);
bool result =- In
Remove.c:1110:
}
VecDeleteRangeFast(&vec, 0, 2);
// Length is now 3; the raw slot at index 4 was part of the vacated tail
- In
Remove.c:1133:
}
VecDeleteRangeFast(&vec, 0, 2);
bool result = (VecLen(&vec) == 3) && (*VecPtrAt(&vec, 4) == 0);- In
Remove.c:1158:
// ~42*count bytes (several MB) past the buffer end, far beyond the mapping.
const u64 K = 80000;
VecDeleteRangeFast(&vec, 0, K);
bool result = (VecLen(&vec) == (u64)N - K);
Last updated on