|
sficl
Current version
|
A light version of std::vector that allows push_back and clear without unnecessary memory operations. More...
#include <SfiVectorLite.h>


Public Member Functions | |
| SfiVectorLite (int size=0) | |
| Initializes the vector to the given size. More... | |
| SfiVectorLite (const SfiVectorLite< T > &vec) | |
| Copy constructor. More... | |
| ~SfiVectorLite () | |
| T & | operator[] (int i) |
| Returns the i-th element of the vector. Can be used as an l-value. More... | |
| const T & | operator[] (int i) const |
| Returns the i-th element of the vector. More... | |
| int | size () const |
| Returns the size of the vector. More... | |
| int | length () const |
| Returns the size of the vector. More... | |
| int | capacity () const |
| Returns the vector's storage capacity. More... | |
| void | reserve (size_t size) |
| Resizes the underlying vector, but does not change the perceived size. More... | |
| void | resize (size_t size) |
| Resizes the vector storage and adds/removes the elements appropriately. More... | |
| void | pack () |
| Resizes the vector to the current number of elements. More... | |
| void | clear () |
| Sets the number of elements to zero without releasing the memory. Use pack() to also release the memory. More... | |
| void | push_back (const T &t) |
| Appends t to the end of the vector. More... | |
| SfiVectorLite< T > & | operator= (const SfiVectorLite< T > &vec) |
| Copies the contents of vec into the vector. More... | |
Private Attributes | |
| vector< T > | m_data |
| The storage for internal data. More... | |
| size_t | m_count |
| The number of elements in the vector. More... | |
A light version of std::vector that allows push_back and clear without unnecessary memory operations.
The intended purpose is a vector that grows by calling push_back() and then clears by calling clear(). In the regular vector, the clear operation releases allocated memory. In this implementation, only the perceived size of the vector is changed, while any memory remains and will be reused on subsequent calls to push_back(). The memory can be released by calling pack().
Definition at line 45 of file SfiVectorLite.h.
|
inlineexplicit |
Initializes the vector to the given size.
Definition at line 56 of file SfiVectorLite.h.
|
inline |
Copy constructor.
Definition at line 62 of file SfiVectorLite.h.
|
inline |
Definition at line 68 of file SfiVectorLite.h.
|
inline |
Returns the vector's storage capacity.
If the vector is attached to external storage, returns the external storage capacity.
Definition at line 101 of file SfiVectorLite.h.
|
inline |
Sets the number of elements to zero without releasing the memory. Use pack() to also release the memory.
Definition at line 130 of file SfiVectorLite.h.
Referenced by SfiDelimitedRecordSTD::clear(), and SfiDelimitedRecordSTD::split().
|
inline |
Returns the size of the vector.
Definition at line 94 of file SfiVectorLite.h.
|
inline |
Copies the contents of vec into the vector.
Definition at line 150 of file SfiVectorLite.h.
|
inline |
Returns the i-th element of the vector. Can be used as an l-value.
Definition at line 73 of file SfiVectorLite.h.
|
inline |
Returns the i-th element of the vector.
Definition at line 78 of file SfiVectorLite.h.
|
inline |
Resizes the vector to the current number of elements.
Can be used to free unused space after removing elements or resizing the vector down.
Definition at line 124 of file SfiVectorLite.h.
|
inline |
Appends t to the end of the vector.
Definition at line 136 of file SfiVectorLite.h.
Referenced by SfiDelimitedRecordSTD::split().
|
inline |
Resizes the underlying vector, but does not change the perceived size.
Definition at line 107 of file SfiVectorLite.h.
Referenced by SfiDelimitedRecordSTD::SfiDelimitedRecordSTD().
|
inline |
Resizes the vector storage and adds/removes the elements appropriately.
Definition at line 115 of file SfiVectorLite.h.
|
inline |
Returns the size of the vector.
Definition at line 89 of file SfiVectorLite.h.
Referenced by SfiDelimitedRecordSTD::get(), SfiDelimitedRecordSTD::length(), SfiDelimitedRecordSTD::offset(), SfiDelimitedRecordSTD::operator[](), SfiVectorLite< int >::resize(), SfiVectorLite< int >::SfiVectorLite(), SfiDelimitedRecordSTD::size(), and SfiDelimitedRecordSTD::split().
|
private |
The number of elements in the vector.
Definition at line 51 of file SfiVectorLite.h.
Referenced by SfiVectorLite< int >::clear(), SfiVectorLite< int >::length(), SfiVectorLite< int >::operator=(), SfiVectorLite< int >::pack(), SfiVectorLite< int >::push_back(), SfiVectorLite< int >::resize(), and SfiVectorLite< int >::size().
|
private |
The storage for internal data.
Definition at line 49 of file SfiVectorLite.h.
Referenced by SfiVectorLite< int >::capacity(), SfiVectorLite< int >::operator=(), SfiVectorLite< int >::operator[](), SfiVectorLite< int >::pack(), SfiVectorLite< int >::push_back(), SfiVectorLite< int >::reserve(), SfiVectorLite< int >::resize(), and SfiVectorLite< int >::SfiVectorLite().
1.8.5