Skip to content

Commit 20b584e

Browse files
committed
FixedVector::push_back_for_overwrite
1 parent a1509d4 commit 20b584e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

util/fixed_vector.hh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ public:
3434
return true;
3535
}
3636

37+
// returns MaxElements for failure
38+
size_t push_back_for_overwrite() {
39+
if (back_idx >= MaxElements)
40+
return MaxElements;
41+
42+
auto idx = back_idx;
43+
44+
back_idx++;
45+
return idx;
46+
}
47+
3748
T pop_back() {
3849
if (back_idx == 0)
3950
return T{};

0 commit comments

Comments
 (0)