원형 |
예 |
설명 |
vector<T>::vector<T>() |
vector<T> c; |
빈 vector c를 생성한다. |
vector<T>::vector<T>(const T& t) |
vector<int> c1(c2); |
같은 type의 원소를 갖는 vector c1을 c2로부터 생성한다. 즉 c2를 복사하여 c1을 만든다. |
vector<T>::vector<T>(size_type vector_size) |
vector<double> c(10); |
T의 default 생성자를 호출하여 만든 type T의 instance n로 c를 채운다. |
vector<T>::vector<T>(size_type element_number, const T& element) |
vector<int> c(10,0); |
type T인 element 원소를 element_number개 생성하여 c에 복사한다. |
vector<T>::vector<T>(iterator first_pos, iterator last_pos) |
code>vector<int> c(old.begin(), old.end()); |
[beg, end)의 원소를 c로 복사하여 초기화한다. |
vector<T>::~vector<T>() |
c.~(); |
메모리를 해제한다. 이 함수를 명시적으로 호출하는 경우는 별로 없다. |
검사 함수 |
|
size_type vector<T>::size() |
int size = (int)c.size(); |
벡터 안에 들어 있는 원소의 갯수를 반환한다. int 타입임을 보장할 수 없는 것에 주의해야 한다. size_type은 compiler마다 다르게 정의되어 있다. |
bool vector<T>::empty() |
if(matrix.empty() == false){ |
벡터 안에 원소가 하나라도 있으면 false를 반환한다. size()==0; 을 호출하는 것보다 효율적이다. |
size_type vector<T>::max_size() |
|
|
size_type vector<T>::capacity() |
|
|
void vector<T>::reserve(size_type new_size) |
a.reserve(file_size); |
벡터에 new_size의 갯수를 저장할 수 있는 공간을 미리 확보한다. |
bool vector<T>::operator==(const vector<T>& new_value) |
if(old_vector == new_vector){ |
|
bool vector<T>::operator!=(const vector<T>& v); |
|
bool vector<T>::operator<(const vector<T>& v); |
|
bool vector<T>::operator>(const vector<T>& v); |
|
bool vector<T>::operator<=(const vector<T>& v); |
|
bool vector<T>::operator>=(const vector<T>& v); |
|
할당 관련 동작 |
|
vector<T>& operator=(const vector<T>& v); |
|
assign(n, elem) |
|
assign(beg, end) |
|
void vector<T>::swap(vector<T>& target_vector) |
|
swap(c1, c2) |
|
at(idx) |
|
T& vector<T>::operator[](size_type index); |
|
const T& vector<T>::front() const |
|
T& vector<T>::back() |
|
반복자 관련 함수들 |
|
const_iterator vector<T>::begin() const |
|
const_iterator vector<T>::end() const |
|
reverse_iteator vector<T>::rbegin() |
|
reverse_iterator vector<T>::rend() |
|
원소의 수정 |
|
iterator vector<T>::insert(iterator pos, const T& t) |
|
void vector<T>::insert(iterator pos, size_type n, const T& t) |
|
void vector<T>::insert(iterator pos, InputIterator begin, InputIterator end) |
|
void vector<T>::push_back(const T& t) |
|
void vector<T>::pop_back() |
|
iterator vector<T>::erase(iterator pos) |
|
iterator vector<T>::erase(iterator beg, iterator end) |
|
void vector<T>::resize(size_type num) |
|
void vector<T>::resize(size_type num, const T& t) |
|
void vector<T>::clear() |
|