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.
| 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); } |