MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / SwapAndPop

Method SwapAndPop

eval/eval/evaluator_stack.h:284–296  ·  view source on GitHub ↗

Swaps the `n - i` element (from the top of the stack) with the `n` element, and pops `n - 1` elements. This results in the `n - i` element being at the top of the stack.

Source from the content-addressed store, hash-verified

282 // and pops `n - 1` elements. This results in the `n - i` element being at the
283 // top of the stack.
284 void SwapAndPop(size_t n, size_t i) {
285 ABSL_DCHECK_GT(n, 0);
286 ABSL_DCHECK_LT(i, n);
287 ABSL_DCHECK(HasEnough(n - 1));
288
289 using std::swap;
290
291 if (i > 0) {
292 swap(*(values_ - n), *(values_ - n + i));
293 swap(*(attributes_ - n), *(attributes_ - n + i));
294 }
295 Pop(n - 1);
296 }
297
298 // Update the max size of the stack and update capacity if needed.
299 void SetMaxSize(size_t size) { Reserve(size); }

Callers 3

EvaluateMethod · 0.80
Evaluate1Method · 0.80
Evaluate2Method · 0.80

Calls 1

swapFunction · 0.50

Tested by

no test coverage detected