![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
A class that uses a linked list to keep track of all the indices of a vector that are equal to a certain value. The values are expected to be lower than the size N of the vector (larger values grow the list heads). More...
#include <index_tracker.hpp>
Classes | |
| class | Reference |
| Proxy reference type for element access with automatic index tracking update. More... | |
Public Member Functions | |
| template<typename U> | |
| IndexTracker (const std::vector< U > &vec) | |
| Constructor from any integral vector. Values are cast to IndexType. | |
| Reference | operator[] (IndexType i) |
| Returns a proxy reference to an element at index i. | |
| IndexType | operator[] (IndexType i) const |
| Const access to element at index i. | |
| std::vector< IndexType > | indicesOf (IndexType v, bool sorted=true) const |
| Returns a vector of all indices whose value equals v. | |
| template<typename F> | |
| void | forEachIndex (IndexType v, F f) const |
| Applies a callback to each index that maps to the given value. | |
| IndexType | size () const |
| Returns the number of tracked elements. | |
| const std::vector< IndexType > & | getValues () const |
| Returns a const reference to the underlying data. | |
Static Public Attributes | |
| static constexpr IndexType | npos = static_cast<IndexType>(-1) |
| Sentinel value used to indicate 'not found'. | |
Private Member Functions | |
| void | updateIndex (IndexType i, IndexType new_v) |
Private Attributes | |
| std::vector< IndexType > | m_data |
| IndexType | m_N {} |
| IndexType | m_V {} |
| std::vector< IndexType > | m_head |
| std::vector< IndexType > | m_next |
| std::vector< IndexType > | m_prev |
Friends | |
| class | Reference |
A class that uses a linked list to keep track of all the indices of a vector that are equal to a certain value. The values are expected to be lower than the size N of the vector (larger values grow the list heads).
|
inlineexplicit |
Constructor from any integral vector. Values are cast to IndexType.
| U | integral type |
| vec | input vector |
|
inline |
Applies a callback to each index that maps to the given value.
| F | Callable object |
| v | value to iterate over |
| f | callback accepting index |
|
inline |
Returns a const reference to the underlying data.
| std::vector< IndexType > vulpes::datastructure::IndexTracker< IndexType >::indicesOf | ( | IndexType | v, |
| bool | sorted = true ) const |
Returns a vector of all indices whose value equals v.
| v | the value to search for |
| sorted | whether to sort the values in the output array. |
| IndexTracker< IndexType >::Reference vulpes::datastructure::IndexTracker< IndexType >::operator[] | ( | IndexType | i | ) |
Returns a proxy reference to an element at index i.
| IndexType vulpes::datastructure::IndexTracker< IndexType >::operator[] | ( | IndexType | i | ) | const |
Const access to element at index i.
|
inline |
Returns the number of tracked elements.
|
private |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
Sentinel value used to indicate 'not found'.