![]() |
Home | Libraries | People | FAQ | More |
boost::container::vector
// In header: <boost/container/vector.hpp> template<typename T, typename A = void, typename Options = void> class vector { public: // types typedef T ; typedef implementation_defined ; typedef ::boost::container::allocator_traits< allocator_type > ; typedef allocator_traits< allocator_type >:: ; typedef allocator_traits< allocator_type >:: ; typedef allocator_traits< allocator_type >:: ; typedef allocator_traits< allocator_type >:: ; typedef allocator_traits< allocator_type >:: ; typedef allocator_traits< allocator_type >:: ; typedef allocator_type ; typedef implementation_defined ; typedef implementation_defined ; typedef implementation_defined ; typedef implementation_defined ; // construct/copy/destruct () ; (const allocator_type &) ; (); (, const allocator_type &); (, default_init_t); (, default_init_t, const allocator_type &); (, const T &); (, const T &, const allocator_type &); template<typename InIt> (InIt, InIt last ); template<typename InIt> (InIt, InIt, const allocator_type &a ); (const vector &); (vector &&) ; (, const allocator_type & = allocator_type()); (const vector &, const allocator_type &); (vector &&, const allocator_type &); vector & (const vector &); vector & (); vector & (vector &&) ; ~(); // public member functions template<typename InIt> void (InIt, InIt last ); void (T >); template<typename FwdIt> void (FwdIt, FwdIt last ); void (, const ); allocator_type () ; stored_allocator_type & () ; const stored_allocator_type & () ; () ; () ; () ; () ; reverse_iterator () ; const_reverse_iterator () ; reverse_iterator () ; const_reverse_iterator () ; () ; () ; const_reverse_iterator () ; const_reverse_iterator () ; bool () ; () ; () ; void (); void (, default_init_t); void (, const T &); () ; void (); void (); reference () ; const_reference () ; reference () ; const_reference () ; reference () ; const_reference () ; () ; () ; () ; () ; reference (); const_reference () ; T * () ; const T * () ; template< Args> reference (Args &&...); template< Args> bool (Args &&...); template< Args> (, Args &&...); void (const T &); void (T &&); (, const T &); (, T &&); (, , const T &); template<typename InIt> (, InIt, InIt); (, ); void () ; (); (, ); void (vector &) ; void () ; // friend functions bool (const vector &, const vector &); bool (const vector &, const vector &); bool (const vector &, const vector &); bool (const vector &, const vector &); bool (const vector &, const vector &); bool (const vector &, const vector &); void (vector &, vector &) ; };
A vector is a sequence that supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle. The number of elements in a vector may vary dynamically; memory management is automatic.
typename T
The type of object that is stored in the vector
typename A = void
The allocator used for all internal memory management, use void for the default allocator
typename Options = void
A type produced from
. boost::container::vector_options
vector
public
construct/copy/destruct() ;
Effects: Constructs a vector taking the allocator as parameter.
Throws: Nothing.
Complexity: Constant.
(const allocator_type & a) ;
Effects: Constructs a vector taking the allocator as parameter.
Throws: Nothing
Complexity: Constant.
( n);
Effects: Constructs a vector and inserts n value initialized values.
Throws: If allocator_type's allocation throws or T's value initialization throws.
Complexity: Linear to n.
( n, const allocator_type & a);
Effects: Constructs a vector that will use a copy of allocator a and inserts n value initialized values.
Throws: If allocator_type's allocation throws or T's value initialization throws.
Complexity: Linear to n.
( n, default_init_t);
Effects: Constructs a vector that will use a copy of allocator a and inserts n default initialized values.
Throws: If allocator_type's allocation throws or T's default initialization throws.
Complexity: Linear to n.
Note: Non-standard extension
( n, default_init_t, const allocator_type & a);
Effects: Constructs a vector that will use a copy of allocator a and inserts n default initialized values.
Throws: If allocator_type's allocation throws or T's default initialization throws.
Complexity: Linear to n.
Note: Non-standard extension
( n, const T & value);
Effects: Constructs a vector and inserts n copies of value.
Throws: If allocator_type's allocation throws or T's copy constructor throws.
Complexity: Linear to n.
( n, const T & value, const allocator_type & a);
Effects: Constructs a vector that will use a copy of allocator a and inserts n copies of value.
Throws: If allocation throws or T's copy constructor throws.
Complexity: Linear to n.
template<typename InIt> (InIt first, InIt last BOOST_CONTAINER_DOCIGN);
Effects: Constructs a vector and inserts a copy of the range [first, last) in the vector.
Throws: If allocator_type's allocation throws or T's constructor taking a dereferenced InIt throws.
Complexity: Linear to the range [first, last).
template<typename InIt> (InIt first, InIt last, const allocator_type &a BOOST_CONTAINER_DOCIGN);
Effects: Constructs a vector that will use a copy of allocator a and inserts a copy of the range [first, last) in the vector.
Throws: If allocator_type's allocation throws or T's constructor taking a dereferenced InIt throws.
Complexity: Linear to the range [first, last).
(const vector & x);
Effects: Copy constructs a vector.
Postcondition: x == *this.
Throws: If allocator_type's allocation throws or T's copy constructor throws.
Complexity: Linear to the elements x contains.
(vector && x) ;
Effects: Move constructor. Moves x's resources to *this.
Throws: Nothing
Complexity: Constant.
( il, const allocator_type & a = allocator_type());
Effects: Constructs a vector that will use a copy of allocator a and inserts a copy of the range [il.begin(), il.last()) in the vector
Throws: If T's constructor taking a dereferenced initializer_list iterator throws.
Complexity: Linear to the range [il.begin(), il.end()).
(const vector & x, const allocator_type & a);
Effects: Copy constructs a vector using the specified allocator.
Postcondition: x == *this.
Throws: If allocation throws or T's copy constructor throws.
Complexity: Linear to the elements x contains.
(vector && x, const allocator_type & a);
Effects: Move constructor using the specified allocator. Moves x's resources to *this if a == allocator_type(). Otherwise copies values from x to *this.
Throws: If allocation or T's copy constructor throws.
Complexity: Constant if a == x.get_allocator(), linear otherwise.
vector & (const vector & x);
Effects: Makes *this contain the same elements as x.
Postcondition: this->size() == x.size(). *this contains a copy of each of x's elements.
Throws: If memory allocation throws or T's copy/move constructor/assignment throws.
Complexity: Linear to the number of elements in x.
vector & ( il);
Effects: Make *this container contains elements from il.
Complexity: Linear to the range [il.begin(), il.end()).
vector & (vector && x) ;
Effects: Move assignment. All x's values are transferred to *this.
Postcondition: x.empty(). *this contains a the elements x had before the function.
Throws: If allocator_traits_type::propagate_on_container_move_assignment is false and (allocation throws or value_type's move constructor throws)
Complexity: Constant if allocator_traits_type:: propagate_on_container_move_assignment is true or this->get>allocator() == x.get_allocator(). Linear otherwise.
~();
Effects: Destroys the vector. All stored values are destroyed and used memory is deallocated.
Throws: Nothing.
Complexity: Linear to the number of elements.
vector
public member functionstemplate<typename InIt> void (InIt first, InIt last BOOST_CONTAINER_DOCIGN);
Effects: Assigns the the range [first, last) to *this.
Throws: If memory allocation throws or T's copy/move constructor/assignment or T's constructor/assignment from dereferencing InpIt throws.
Complexity: Linear to n.
void (T > il);
Effects: Assigns the the range [il.begin(), il.end()) to *this.
Throws: If memory allocation throws or T's constructor from dereferencing iniializer_list iterator throws.
template<typename FwdIt> void (FwdIt first, FwdIt last BOOST_CONTAINER_DOCIGN);
Effects: Assigns the the range [first, last) to *this.
Throws: If memory allocation throws or T's copy/move constructor/assignment or T's constructor/assignment from dereferencing InpIt throws.
Complexity: Linear to n.
void ( n, const val);
Effects: Assigns the n copies of val to *this.
Throws: If memory allocation throws or T's copy/move constructor/assignment throws.
Complexity: Linear to n.
allocator_type () ;
Effects: Returns a copy of the internal allocator.
Throws: If allocator's copy constructor throws.
Complexity: Constant.
stored_allocator_type & () ;
Effects: Returns a reference to the internal allocator.
Throws: Nothing
Complexity: Constant.
Note: Non-standard extension.
const stored_allocator_type & () ;
Effects: Returns a reference to the internal allocator.
Throws: Nothing
Complexity: Constant.
Note: Non-standard extension.
() ;
Effects: Returns an iterator to the first element contained in the vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns a const_iterator to the first element contained in the vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns an iterator to the end of the vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns a const_iterator to the end of the vector.
Throws: Nothing.
Complexity: Constant.
reverse_iterator () ;
Effects: Returns a reverse_iterator pointing to the beginning of the reversed vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.
Throws: Nothing.
Complexity: Constant.
reverse_iterator () ;
Effects: Returns a reverse_iterator pointing to the end of the reversed vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns a const_iterator to the first element contained in the vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns a const_iterator to the end of the vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator () ;
Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.
Throws: Nothing.
Complexity: Constant.
bool () ;
Effects: Returns true if the vector contains no elements.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns the number of the elements contained in the vector.
Throws: Nothing.
Complexity: Constant.
() ;
Effects: Returns the largest possible size of the vector.
Throws: Nothing.
Complexity: Constant.
void ( new_size);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are value initialized.
Throws: If memory allocation throws, or T's copy/move or value initialization throws.
Complexity: Linear to the difference between size() and new_size.
void ( new_size, default_init_t);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are default initialized.
Throws: If memory allocation throws, or T's copy/move or default initialization throws.
Complexity: Linear to the difference between size() and new_size.
Note: Non-standard extension
void ( new_size, const T & x);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are copy constructed from x.
Throws: If memory allocation throws, or T's copy/move constructor throws.
Complexity: Linear to the difference between size() and new_size.
() ;
Effects: Number of elements for which memory has been allocated. capacity() is always greater than or equal to size().
Throws: Nothing.
Complexity: Constant.
void ( new_cap);
Effects: If n is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
Throws: If memory allocation allocation throws or T's copy/move constructor throws.
void ();
Effects: Tries to deallocate the excess of memory created with previous allocations. The size of the vector is unchanged
Throws: If memory allocation throws, or T's copy/move constructor throws.
Complexity: Linear to size().
reference () ;
Requires: !empty()
Effects: Returns a reference to the first element of the container.
Throws: Nothing.
Complexity: Constant.
const_reference () ;
Requires: !empty()
Effects: Returns a const reference to the first element of the container.
Throws: Nothing.
Complexity: Constant.
reference () ;
Requires: !empty()
Effects: Returns a reference to the last element of the container.
Throws: Nothing.
Complexity: Constant.
const_reference () ;
Requires: !empty()
Effects: Returns a const reference to the last element of the container.
Throws: Nothing.
Complexity: Constant.
reference ( n) ;
Requires: size() > n.
Effects: Returns a reference to the nth element from the beginning of the container.
Throws: Nothing.
Complexity: Constant.
const_reference ( n) ;
Requires: size() > n.
Effects: Returns a const reference to the nth element from the beginning of the container.
Throws: Nothing.
Complexity: Constant.
( n) ;
Requires: size() >= n.
Effects: Returns an iterator to the nth element from the beginning of the container. Returns end() if n == size().
Throws: Nothing.
Complexity: Constant.
Note: Non-standard extension
( n) ;
Requires: size() >= n.
Effects: Returns a const_iterator to the nth element from the beginning of the container. Returns end() if n == size().
Throws: Nothing.
Complexity: Constant.
Note: Non-standard extension
( p) ;
Requires: begin() <= p <= end().
Effects: Returns the index of the element pointed by p and size() if p == end().
Throws: Nothing.
Complexity: Constant.
Note: Non-standard extension
( p) ;
Requires: begin() <= p <= end().
Effects: Returns the index of the element pointed by p and size() if p == end().
Throws: Nothing.
Complexity: Constant.
Note: Non-standard extension
reference ( n);
Requires: size() > n.
Effects: Returns a reference to the nth element from the beginning of the container.
Throws: range_error if n >= size()
Complexity: Constant.
const_reference ( n) ;
Requires: size() > n.
Effects: Returns a const reference to the nth element from the beginning of the container.
Throws: range_error if n >= size()
Complexity: Constant.
T * () ;
Returns: A pointer such that [data(),data() + size()) is a valid range. For a non-empty vector, data() == &front().
Throws: Nothing.
Complexity: Constant.
const T * () ;
Returns: A pointer such that [data(),data() + size()) is a valid range. For a non-empty vector, data() == &front().
Throws: Nothing.
Complexity: Constant.
template< Args> reference (Args &&... args);
Effects: Inserts an object of type T constructed with std::forward<Args>(args)... in the end of the vector.
Returns: A reference to the created object.
Throws: If memory allocation throws or the in-place constructor throws or T's copy/move constructor throws.
Complexity: Amortized constant time.
template< Args> bool (Args &&... args);
Effects: Inserts an object of type T constructed with std::forward<Args>(args)... in the end of the vector.
Throws: If the in-place constructor throws.
Complexity: Constant time.
Note: Non-standard extension.
template< Args> ( position, Args &&... args);
Requires: position must be a valid iterator of *this.
Effects: Inserts an object of type T constructed with std::forward<Args>(args)... before position
Throws: If memory allocation throws or the in-place constructor throws or T's copy/move constructor/assignment throws.
Complexity: If position is end(), amortized constant time Linear time otherwise.
void (const T & x);
Effects: Inserts a copy of x at the end of the vector.
Throws: If memory allocation throws or T's copy/move constructor throws.
Complexity: Amortized constant time.
void (T && x);
Effects: Constructs a new element in the end of the vector and moves the resources of x to this new element.
Throws: If memory allocation throws or T's copy/move constructor throws.
Complexity: Amortized constant time.
( position, const T & x);
Requires: position must be a valid iterator of *this.
Effects: Insert a copy of x before position.
Throws: If memory allocation throws or T's copy/move constructor/assignment throws.
Complexity: If position is end(), amortized constant time Linear time otherwise.
( position, T && x);
Requires: position must be a valid iterator of *this.
Effects: Insert a new element before position with x's resources.
Throws: If memory allocation throws.
Complexity: If position is end(), amortized constant time Linear time otherwise.
( p, n, const T & x);
Requires: p must be a valid iterator of *this.
Effects: Insert n copies of x before pos.
Returns: an iterator to the first inserted element or p if n is 0.
Throws: If memory allocation throws or T's copy/move constructor throws.
Complexity: Linear to n.
template<typename InIt> ( pos, InIt first, InIt last);
Requires: p must be a valid iterator of *this.
Effects: Insert a copy of the [first, last) range before pos.
Returns: an iterator to the first inserted element or pos if first == last.
Throws: If memory allocation throws, T's constructor from a dereferenced InpIt throws or T's copy/move constructor/assignment throws.
Complexity: Linear to boost::container::iterator_distance [first, last).
( position, il);
Requires: p must be a valid iterator of *this. num, must be equal to boost::container::iterator_distance(first, last)
Effects: Insert a copy of the [first, last) range before pos.
Returns: an iterator to the first inserted element or pos if first == last.
Throws: If memory allocation throws, T's constructor from a dereferenced InpIt throws or T's copy/move constructor/assignment throws.
Complexity: Linear to boost::container::iterator_distance [first, last).
Note: This function avoids a linear operation to calculate boost::container::iterator_distance[first, last) for forward and bidirectional iterators, and a one by one insertion for input iterators. This is a a non-standard extension. Requires: position must be a valid iterator of *this.
Effects: Insert a copy of the [il.begin(), il.end()) range before position.
Returns: an iterator to the first inserted element or position if first == last.
Complexity: Linear to the range [il.begin(), il.end()).
void () ;
Effects: Removes the last element from the container.
Throws: Nothing.
Complexity: Constant time.
( position);
Effects: Erases the element at position pos.
Throws: Nothing.
Complexity: Linear to the elements between pos and the last element. Constant if pos is the last element.
( first, last);
Effects: Erases the elements pointed by [first, last).
Throws: Nothing.
Complexity: Linear to the distance between first and last plus linear to the elements between pos and the last element.
void (vector & x) ;
Effects: Swaps the contents of *this and x.
Throws: Nothing.
Complexity: Constant.
void () ;
Effects: Erases all the elements of the vector.
Throws: Nothing.
Complexity: Linear to the number of elements in the container.
vector
friend functionsbool (const vector & x, const vector & y);
Effects: Returns true if x and y are equal
Complexity: Linear to the number of elements in the container.
bool (const vector & x, const vector & y);
Effects: Returns true if x and y are unequal
Complexity: Linear to the number of elements in the container.
bool (const vector & x, const vector & y);
Effects: Returns true if x is less than y
Complexity: Linear to the number of elements in the container.
bool (const vector & x, const vector & y);
Effects: Returns true if x is greater than y
Complexity: Linear to the number of elements in the container.
bool (const vector & x, const vector & y);
Effects: Returns true if x is equal or less than y
Complexity: Linear to the number of elements in the container.
bool (const vector & x, const vector & y);
Effects: Returns true if x is equal or greater than y
Complexity: Linear to the number of elements in the container.
void (vector & x, vector & y) ;
Effects: x.swap(y)
Complexity: Constant.