Skip to content

Commit d5d257e

Browse files
committed
Erases all elements from the container vector
1 parent 882bef9 commit d5d257e

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ for (vector<int>::iterator p=a.begin(); p!=a.end(); ++p)
430430
vector<int> b(a.begin(), a.end()); // b is copy of a
431431
vector<T> c(n, x); // c[0]..c[n-1] init to x
432432
T d[10]; vector<T> e(d, d+10); // e is initialized from d
433+
a.clear(); // Erases all elements from the container. Leaves the capacity() of the vector unchanged.
433434
```
434435

435436
## `deque` (Array stack queue)

cheatsheet-as-sourcefile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ for (vector<int>::iterator p=a.begin(); p!=a.end(); ++p)
402402
vector<int> b(a.begin(), a.end()); // b is copy of a
403403
vector<T> c(n, x); // c[0]..c[n-1] init to x
404404
T d[10]; vector<T> e(d, d+10); // e is initialized from d
405+
a.clear(); // Erases all elements from the container. Leaves the capacity() of the vector unchanged.
405406

406407
// ## `deque` (Array stack queue)
407408

0 commit comments

Comments
 (0)