template<class T>class std::vector
{
public:
vector();
//Default constructor
//Precondition :None;
//Postcondition :An empty vector exists.
vector(size_type n);
//Creates a vector with n elements
//Precondition :None;
//Postcondition :A vector of n elements exists
bool empty()const;
//Detemines whether the vector is empty
//Precondition :None;
//Postcondition :Return true if the vector is empty
//otherwise returns false
size_type size()const;
//Detemines the length of the vector
//the return type size_type is an integral type
//Precondition :None;
//Postcondition :returns the number of the items that
//are currenty in the vector
void push_back(const T &)
//Inserts a new element at the end of the vector.
//precondition :none
//postcondition :the new element is the last element
//in vector
void pop_back();
//removes the last element of the vector
//Precondition :there is at least one element in the
//vector
//postcondition :the last element of the vector is removed
iterator insert(interator i,const T &);
//Insert an item into the vector
//before the element specified by the iterator
//Precondition :the iterator is initialized
//postcondition :Item val is inserted into the vector
//and an iterator to the newly inserted item is return
iterator erase(iterator i);
//remove element at i
//precondition : the iterator must be initialized
//postcondition :returns the iterators to the item
//following the removed item
void clear();
//Erases all the elements in the vector
//precondition :NOne;
//postcondition :the vector has no elements
iterator begin();
//returns an iterator to the first item in the vector
//precondition :None;
//postcondition :if the vector is empty
//the value returned by the end() is returned
iterator end();
//returns an iterator to test for the end of
//the vector
//precondition :None;
//Postcondition :the value for the end of the vector
//was returned
};
stl类vector
最新推荐文章于 2024-11-13 20:18:53 发布