MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / normalizeIndices

Function normalizeIndices

src/function/list/list_slice_function.cpp:10–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace function {
9
10static void normalizeIndices(int64_t& startIdx, int64_t& endIdx, uint64_t size) {
11 if (startIdx < 0) {
12 startIdx = size + startIdx + 1;
13 }
14 if (startIdx <= 0) {
15 startIdx = 1;
16 }
17 if (endIdx < 0) {
18 endIdx = size + endIdx + 1;
19 }
20 if (endIdx > (int64_t)size) {
21 endIdx = size;
22 }
23 if (endIdx < startIdx) {
24 startIdx = 1;
25 endIdx = 0;
26 }
27}
28
29struct ListSlice {
30 // Note: this function takes in a 1-based begin/end index (The index of the first value in the

Callers 1

operationMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected