libcrn
3.9.5
A document image processing library
|
#include <CRNVector.h>
Public Member Functions | |
Vector () | |
Default constructor. More... | |
virtual | ~Vector () override |
Destructor. More... | |
Vector (const Vector &) | |
Vector (Vector &&)=default | |
Vector & | operator= (const Vector &) |
Vector & | operator= (Vector &&)=default |
size_t | Size () const noexcept |
Returns the number of data objects in the vector. More... | |
bool | IsEmpty () const noexcept |
Tests if the vector is empty. More... | |
SObject & | operator[] (size_t i) |
Returns an object from index (unsafe) More... | |
SCObject | operator[] (size_t i) const |
Returns an object from index (unsafe) More... | |
SObject & | At (size_t i) |
Returns an object from index (unsafe) More... | |
SCObject | At (size_t i) const |
Returns an object from index (unsafe) More... | |
SObject & | Front () |
Returns a reference to the first element. More... | |
SCObject | Front () const |
Returns a reference to the first element. More... | |
SObject & | Back () |
Returns a reference to the last element. More... | |
SCObject | Back () const |
Returns a reference to the last element. More... | |
bool | Contains (const SCObject &o) const |
Checks of the object is in the vector. More... | |
void | PushBack (const SObject &d) |
Adds an object at the end of the vector. More... | |
void | Insert (const SObject &d, size_t pos) |
Inserts an object at a given position. More... | |
void | ReorderFrom (const std::vector< size_t > &from) |
Reorders the elements. More... | |
void | ReorderTo (const std::vector< size_t > &to) |
Reorders the elements. More... | |
void | PopBack () |
Removes the last element. More... | |
void | Remove (size_t index) |
Removes an element (safe) More... | |
void | Remove (const SCObject &obj) |
Removes an element (safe) More... | |
void | Clear () noexcept |
Empties the vector. More... | |
iterator | begin () |
Returns an iterator to the first element. More... | |
iterator | end () |
Returns a iterator to the end of the list. More... | |
const_iterator | begin () const |
Returns a const iterator to the first element. More... | |
const_iterator | end () const |
Returns a const iterator to the end of the list. More... | |
const_iterator | cbegin () const |
Returns a const iterator to the first element. More... | |
const_iterator | cend () const |
Returns a const iterator to the end of the list. More... | |
void | Remove (iterator it) |
Removes element. More... | |
void | Remove (iterator begin, iterator end) |
Removes elements. More... | |
template<class Predicate > | |
void | RemoveIf (Predicate pred) |
Removes elements if predicate is true. More... | |
const_iterator | Find (const SCObject &o) const |
Finds an object in the container. More... | |
iterator | Find (const SCObject &o) |
Finds an object in the container. More... | |
template<typename T > | |
std::vector< std::shared_ptr< T > > | ToStd () |
Converts to a std::vector of pointers. More... | |
template<typename T > | |
std::vector< std::shared_ptr < const T > > | ToStd () const |
Converts to a std::vector of pointers. More... | |
std::vector< SObject > | Std ()&& |
Gets the inner data. More... | |
void | Swap (Vector &other) noexcept |
Swaps contents with another vector. More... | |
void | ShrinkToFit () |
Optimizes the memory usage. More... | |
void | Deserialize (xml::Element &el) |
Reads from an XML node if applicable. More... | |
xml::Element | Serialize (xml::Element &parent) const |
Dumps to an XML node if applicable. More... | |
Vector (xml::Element &el) | |
![]() | |
virtual | ~Object ()=default |
|
default |
Default constructor.
Default constructor
[in] | protos | the mandatory protocols for the contents |
|
overridevirtualdefault |
Destructor.
Destructor
Vector::Vector | ( | const Vector & | other | ) |
Definition at line 42 of file CRNVector.cpp.
|
default |
|
inline |
Definition at line 159 of file CRNVector.h.
|
inline |
Returns an object from index (unsafe)
Definition at line 65 of file CRNVector.h.
|
inline |
Returns an object from index (unsafe)
Definition at line 67 of file CRNVector.h.
|
inline |
Returns a reference to the last element.
Definition at line 74 of file CRNVector.h.
|
inline |
Returns a reference to the last element.
Definition at line 76 of file CRNVector.h.
|
inline |
Returns an iterator to the first element.
Definition at line 100 of file CRNVector.h.
|
inline |
Returns a const iterator to the first element.
Definition at line 104 of file CRNVector.h.
|
inline |
Returns a const iterator to the first element.
Definition at line 108 of file CRNVector.h.
|
inline |
Returns a const iterator to the end of the list.
Definition at line 110 of file CRNVector.h.
|
inlinenoexcept |
Empties the vector.
Definition at line 96 of file CRNVector.h.
bool Vector::Contains | ( | const SCObject & | o | ) | const |
Checks of the object is in the vector.
Checks of the object is in the vector
[in] | o | the object to check |
Definition at line 72 of file CRNVector.cpp.
void Vector::Deserialize | ( | xml::Element & | el | ) |
Reads from an XML node if applicable.
Unsafe load
ExceptionProtocol | the content of the vector is not serializable |
ExceptionInvalidArgument | not a Vector |
ExceptionRuntime | impossible to read an XML element |
ExceptionNotFound | unknown type |
[in] | el | the element to load |
Definition at line 267 of file CRNVector.cpp.
|
inline |
Returns a iterator to the end of the list.
Definition at line 102 of file CRNVector.h.
|
inline |
Returns a const iterator to the end of the list.
Definition at line 106 of file CRNVector.h.
Vector::const_iterator Vector::Find | ( | const SCObject & | o | ) | const |
Finds an object in the container.
Finds an object in the container
[in] | o | the object to find |
Definition at line 86 of file CRNVector.cpp.
Vector::iterator Vector::Find | ( | const SCObject & | o | ) |
Finds an object in the container.
Finds an object in the container
[in] | o | the object to find |
Definition at line 100 of file CRNVector.cpp.
|
inline |
Returns a reference to the first element.
Definition at line 70 of file CRNVector.h.
|
inline |
Returns a reference to the first element.
Definition at line 72 of file CRNVector.h.
void Vector::Insert | ( | const SObject & | d, |
size_t | pos | ||
) |
Inserts an object at a given position.
Inserts an object at a given position
ExceptionProtocol | object has wrong protocols |
ExceptionDomain | index out of bounds |
[in] | d | the object to add |
[in] | pos | the position |
Definition at line 117 of file CRNVector.cpp.
|
inlinenoexcept |
Tests if the vector is empty.
Definition at line 58 of file CRNVector.h.
Definition at line 48 of file CRNVector.cpp.
|
inline |
Returns an object from index (unsafe)
Definition at line 61 of file CRNVector.h.
|
inline |
Returns an object from index (unsafe)
Definition at line 63 of file CRNVector.h.
|
inline |
Removes the last element.
Definition at line 90 of file CRNVector.h.
void Vector::PushBack | ( | const SObject & | d | ) |
Adds an object at the end of the vector.
Adds an object at the end of the list
[in] | d | the object to add |
Definition at line 61 of file CRNVector.cpp.
void Vector::Remove | ( | size_t | index | ) |
Removes an element (safe)
Removes an element by index
ExceptionDomain | index out of bounds |
[in] | index | the index of the element to remove |
Definition at line 213 of file CRNVector.cpp.
void Vector::Remove | ( | const SCObject & | obj | ) |
Removes an element (safe)
Removes an element by pointer
ExceptionNotFound | object not found. |
[in] | obj | the objet to remove |
Definition at line 226 of file CRNVector.cpp.
void Vector::Remove | ( | iterator | it | ) |
Removes element.
Removes element
[in] | it | an iterator on the object to remove |
Definition at line 241 of file CRNVector.cpp.
Removes elements.
Removes elements
[in] | begin | an iterator on the first object to remove |
[in] | end | an iterator after the last object to remove |
Definition at line 251 of file CRNVector.cpp.
|
inline |
Removes elements if predicate is true.
Definition at line 117 of file CRNVector.h.
void Vector::ReorderFrom | ( | const std::vector< size_t > & | from | ) |
Reorders the elements.
Reorders the elements
ExceptionDimension | changeset is of wrong size |
ExceptionLogic | changeset contains duplicates |
ExceptionDomain | changeset contains values out of bounds |
[in] | from | a vector containing the previous index of each element |
Definition at line 139 of file CRNVector.cpp.
void Vector::ReorderTo | ( | const std::vector< size_t > & | to | ) |
Reorders the elements.
Reorders the elements
ExceptionDimension | changeset is of wrong size |
ExceptionLogic | changeset contains duplicates |
ExceptionDomain | changeset contains values out of bounds |
[in] | to | a vector containing the new index of each element |
Definition at line 177 of file CRNVector.cpp.
xml::Element Vector::Serialize | ( | xml::Element & | parent | ) | const |
Dumps to an XML node if applicable.
Unsafe save
ExceptionProtocol | the content of the vector is not serializable |
[in] | parent | the parent element to which we will add the new element |
Definition at line 308 of file CRNVector.cpp.
void Vector::ShrinkToFit | ( | ) |
Optimizes the memory usage.
Optimizes the memory usage
Definition at line 332 of file CRNVector.cpp.
|
inlinenoexcept |
Returns the number of data objects in the vector.
Definition at line 56 of file CRNVector.h.
|
inline |
Gets the inner data.
Definition at line 141 of file CRNVector.h.
|
noexcept |
Swaps contents with another vector.
Swaps contents with another vector
[in] | other | the vector to swap with |
Definition at line 326 of file CRNVector.cpp.
|
inline |
Converts to a std::vector of pointers.
Definition at line 125 of file CRNVector.h.
|
inline |
Converts to a std::vector of pointers.
Definition at line 133 of file CRNVector.h.