please use vector
This commit is contained in:
23
LinearList/vector/define.cpp
Normal file
23
LinearList/vector/define.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
vector<int> a;
|
||||||
|
vector<int> b(3,100);//b = {100, 100, 100}
|
||||||
|
vector<int> c(b.begin(),b.end());
|
||||||
|
vector<int> d(c);
|
||||||
|
|
||||||
|
for(/*vector<int>::iterator*/ auto ti = b.begin(); ti != b.end(); ti++){
|
||||||
|
cout << *ti << " ";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
b.push_back(300);
|
||||||
|
b.push_back(500);
|
||||||
|
|
||||||
|
cout << b.size() << " " << b.capacity() << endl;
|
||||||
|
b.resize(10);
|
||||||
|
cout << b.size() << " " << b.capacity() << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
LinearList/vector/define.exe
Normal file
BIN
LinearList/vector/define.exe
Normal file
Binary file not shown.
48
LinearList/vector/vector.md
Normal file
48
LinearList/vector/vector.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
Member functions
|
||||||
|
(constructor) Construct vector (public member function)
|
||||||
|
(destructor) Vector destructor (public member function)
|
||||||
|
operator= Assign content (public member function)
|
||||||
|
|
||||||
|
Iterators:
|
||||||
|
begin Return iterator to beginning (public member function)
|
||||||
|
end Return iterator to end (public member function)
|
||||||
|
rbegin Return reverse iterator to reverse beginning (public member function)
|
||||||
|
rend Return reverse iterator to reverse end (public member function)
|
||||||
|
cbegin Return const_iterator to beginning (public member function)
|
||||||
|
cend Return const_iterator to end (public member function)
|
||||||
|
crbegin Return const_reverse_iterator to reverse beginning (public member function)
|
||||||
|
crend Return const_reverse_iterator to reverse end (public member function)
|
||||||
|
|
||||||
|
Capacity:
|
||||||
|
size Return size (public member function)
|
||||||
|
max_size Return maximum size (public member function)
|
||||||
|
resize Change size (public member function)
|
||||||
|
capacity Return size of allocated storage capacity (public member function)
|
||||||
|
empty Test whether vector is empty (public member function)
|
||||||
|
reserve Request a change in capacity (public member function)
|
||||||
|
shrink_to_fit Shrink to fit (public member function)
|
||||||
|
|
||||||
|
Element access:
|
||||||
|
operator[] Access element (public member function)
|
||||||
|
at Access element (public member function)
|
||||||
|
front Access first element (public member function)
|
||||||
|
back Access last element (public member function)
|
||||||
|
data Access data (public member function)
|
||||||
|
|
||||||
|
Modifiers:
|
||||||
|
assign Assign vector content (public member function)
|
||||||
|
push_back Add element at the end (public member function)
|
||||||
|
pop_back Delete last element (public member function)
|
||||||
|
insert Insert elements (public member function)
|
||||||
|
erase Erase elements (public member function)
|
||||||
|
swap Swap content (public member function)
|
||||||
|
clear Clear content (public member function)
|
||||||
|
emplace Construct and insert element (public member function)
|
||||||
|
emplace_back Construct and insert element at the end (public member function)
|
||||||
|
|
||||||
|
Allocator:
|
||||||
|
get_allocator Get allocator (public member function)
|
||||||
|
|
||||||
|
Non-member function overloads
|
||||||
|
relational operators Relational operators for vector (function template)
|
||||||
|
swap Exchange contents of vectors (function template)
|
Reference in New Issue
Block a user