Flow123d
JS_before_hm-2-g912b55d
|
Envelop over std::vector, use enhanced iterators. More...
#include <sys_vector.hh>
Public Types | |
typedef T | ElementType |
We have to export template type for FullIteraror. More... | |
typedef T * | Iter |
Default iterator for this class. More... | |
typedef std::vector< T >::iterator | iterator |
typedef std::vector< T >::const_iterator | const_iterator |
typedef FullIterator< Vector< T > > | FullIter |
Type of FullIterator that should be used to iterate through this container. More... | |
Public Member Functions | |
Vector (unsigned int size=0) | |
Construct with reserve the space. Includes default constructor. More... | |
FullIter | add_item () |
unsigned int | index (Iter pointer) const |
FullIter | begin () |
Returns FullFullIterer of the first element. More... | |
FullIter | end () |
Returns FullFullIterer of the fictions past the end element. More... | |
unsigned int | size () const |
Returns size of the container. This is independent of the allocated space. More... | |
void | resize (const unsigned int size) |
Returns size of the container. This is independent of the allocated space. More... | |
T & | operator[] (unsigned int idx) |
Gets reference to the element specified by index. More... | |
const T & | operator[] (unsigned int idx) const |
Gets reference to the element specified by index. More... | |
FullIter | operator() (unsigned int idx) |
Gets iterator of the element specified by index. More... | |
void | reserve (unsigned int size) |
Reallocates the container space. More... | |
FullIter | full_iter (Iter it) |
virtual | ~Vector () |
Since storage is direct member it is deallocated by its own destructor. More... | |
Protected Attributes | |
std::vector< T > | storage |
Underlying vector container. More... | |
Friends | |
class | FullIterator< Vector< T > > |
Envelop over std::vector, use enhanced iterators.
Differences compared to std::vector.
Developer note:
It appears very dangerous to combine reallocating std::vectors with iterators implemented as pointers. Indeed, when vector array is reallocated old pointers become invalid. One possibility is to strictly distinguish crating of the array and later creating references into it. Another is to implement iterators by indexes which means also to use only FullIterators.
Definition at line 206 of file sys_vector.hh.
typedef std::vector<T>::const_iterator flow::Vector< T >::const_iterator |
Definition at line 216 of file sys_vector.hh.
typedef T flow::Vector< T >::ElementType |
We have to export template type for FullIteraror.
Definition at line 210 of file sys_vector.hh.
typedef FullIterator<Vector<T> > flow::Vector< T >::FullIter |
Type of FullIterator that should be used to iterate through this container.
Definition at line 218 of file sys_vector.hh.
typedef T* flow::Vector< T >::Iter |
Default iterator for this class.
Definition at line 212 of file sys_vector.hh.
typedef std::vector<T>::iterator flow::Vector< T >::iterator |
For compatibility with std::algorithms we provide also standard iterators. Theoretically it should work also with Iter. Test that if you need it.
Definition at line 215 of file sys_vector.hh.
|
inline |
Construct with reserve the space. Includes default constructor.
Definition at line 222 of file sys_vector.hh.
|
inlinevirtual |
Since storage is direct member it is deallocated by its own destructor.
Definition at line 300 of file sys_vector.hh.
|
inline |
Add a new element into the container. Return iterator to it. Provides a way to add new element to the container and get an iterator to set its values. This way we need not copy a new element.
Definition at line 230 of file sys_vector.hh.
|
inline |
Returns FullFullIterer of the first element.
Definition at line 247 of file sys_vector.hh.
|
inline |
Returns FullFullIterer of the fictions past the end element.
Definition at line 251 of file sys_vector.hh.
|
inline |
Alternative way to make FullIterer form Iter. This way you need not write the full FullIter type to call the constructor. Then the result can be assigned to suitable local FullIter variable.
Definition at line 296 of file sys_vector.hh.
|
inline |
For given pointer returns the index of the element in the Vector. The first element has zero index.
Definition at line 239 of file sys_vector.hh.
|
inline |
Gets iterator of the element specified by index.
Definition at line 279 of file sys_vector.hh.
|
inline |
Gets reference to the element specified by index.
Definition at line 264 of file sys_vector.hh.
|
inline |
Gets reference to the element specified by index.
Definition at line 271 of file sys_vector.hh.
|
inline |
Reallocates the container space.
Definition at line 287 of file sys_vector.hh.
|
inline |
Returns size of the container. This is independent of the allocated space.
Definition at line 259 of file sys_vector.hh.
|
inline |
Returns size of the container. This is independent of the allocated space.
Definition at line 255 of file sys_vector.hh.
|
friend |
Definition at line 306 of file sys_vector.hh.
|
protected |
Underlying vector container.
Definition at line 304 of file sys_vector.hh.