Welcome to VectorPro's Tutorial WebSite
Source code is here.
vector_pro
C++template < class value_type > class vector_pro; // generic template
Same as std::vectors, vector_pros are sequence containers representing arrays that can change in size.
vector_pros use contiguous storage locations for their elements. Unlike arrays, their size can change dynamically, with their storage being handled automatically by the container.
Not having much differences with vectors, vector_pros use a dynamically allocated array to store their elements. Instead of reallocating each time an element is added to the container, vector_pro containers may allocate some extra storage to accommodate for possible growth, and thus the container may have an actual capacity greater than the storage strictly needed to contain its elements. However out library currently not support users to self-implement different strategies for memory growth, we just simply double the capacity at logarithmically growing intervals of size so that the insertion of individual elements at the end of the vector can be provided with amortized constant time complexity.
Most of the above text are just copied from std::vector .
Template parameters
C++template <class value_type>
Only if value_type is guaranteed to not throw while moving, implementations can optimize to move elements instead of copying them during reallocations.
Member types and Macros
| member type |
definition |
notes |
iterator_pro |
a random access iterator to value_type |
convertible to const_iterator_pro, more info in iterator_pro |
const_iterator_pro |
a random access iterator to const value_type |
more info in const_iterator_pro |
vector_pro_exception |
exception |
inherits from std::exception, more info in vector_pro_exception |
size_type |
an unsigned integral type |
in a 64-bit system will be int64_t; 32-bit system will be int32_t; the others will just be long int. |
VECTOR_PRO_DEFAULT_SIZE |
initial size of a vector |
default will be 64, self-defined is available |
Member functions
| name |
notes |
| (constructor) |
Construct vector (public member function) |
| (destructor) |
Vector destructor (public member function) |
| operator= |
Assign content (public member function) |
Itertators
| name |
notes |
| begin |
Return an iterator to beginning (public member function) |
| end |
Return an iterator to end (public member function) |
| rbegin |
Return a reverse iterator to reverse beginning (public member function) |
| rend |
Return a reverse iterator to reverse end (public member function) |
| cbegin |
Return a const iterator to beginning (public member function) |
| cend |
Return a const iterator to end (public member function) |
| crbegin |
Return a const reverse iterator to reverse beginning (public member function) |
| crend |
Return a const reverse iterator to reverse end (public member function) |
Capacity
| name |
notes |
| 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
| name |
notes |
| 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 |
Modifiers
| name |
notes |
| 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) |
Differences from std::vector
| name |
notes |
| find |
Find an element in the vector (public member function) |
| merge |
Copy another vector to the end (public member function) |
| not_empty |
Test whether vector is not empty (public member function) |
| operator<< |
Turn the vector into an std::ostream (public friend member function) |
| pop |
Delete last element from the vector and return a copy back (public member function) |
| print |
Print the vector (public member function) |
| push |
Add an element at the end (public member function) |
| reverse |
Reverse the vector (public member function) |
| sort |
Sort the vector (public member function) |