10#ifdef TTK_ENABLE_OPENMP
16#ifndef TTK_ENABLE_KAMIKAZE
22 template <
typename type>
27 const type defaultValue;
31 : std::vector<type>(), nextId(0), defaultValue{dv} {
32#ifndef TTK_ENABLE_KAMIKAZE
34 std::cout <<
"Caution, Atomic vector need a non-0 init size !"
36 std::vector<type>::resize(1, defaultValue);
40 std::vector<type>::resize(initSize, defaultValue);
46 : std::vector<type>(other), nextId(other.nextId) {
47#ifndef TTK_ENABLE_KAMIKAZE
48 if(!std::vector<type>::size()) {
64 void reserve(
const std::size_t &newSize) {
65 if(newSize > std::vector<type>::size()) {
66#ifndef TTK_ENABLE_KAMIKAZE
67#ifdef TTK_ENABLE_OPENMP
68 if(omp_in_parallel()) {
71#pragma omp critical(AtomicUFReserve)
72 { std::vector<type>::resize(newSize, defaultValue); }
78 std::vector<type>::resize(newSize, defaultValue);
83 void reset(
const std::size_t &nId = 0) {
84#ifdef TTK_ENABLE_OPENMP
85#pragma omp atomic write
94 std::size_t
const oldSize = std::vector<type>::size();
95 std::vector<type>::clear();
101#ifdef TTK_ENABLE_OPENMP
102#pragma omp atomic capture
106 if(nextId == std::vector<type>::size()) {
107 reserve(std::vector<type>::size() * 2);
122 const auto &curPos =
getNext();
123 (*this)[curPos] = elmt;
132 std::vector<type>::operator=(other);
133 nextId = other.nextId;
143 using iterator =
typename std::vector<type>::iterator;
147 return this->
begin() + nextId;
151 return this->cbegin() + nextId;
154 using riterator =
typename std::vector<type>::reverse_iterator;
158 return this->rend() - (nextId - 1);
162 return this->crend() - (nextId - 1);
TTK processing package that manage a parallel vecrion of vector.
typename std::vector< type >::const_reverse_iterator const_riterator
virtual ~FTMAtomicVector()=default
FTMAtomicVector(const FTMAtomicVector &other)
typename std::vector< type >::iterator iterator
FTMAtomicVector(FTMAtomicVector &&other) noexcept=default
const_iterator cend() const
void reset(const std::size_t &nId=0)
FTMAtomicVector(const std::size_t initSize=1, const type &dv=type{})
FTMAtomicVector< type > & operator=(const FTMAtomicVector< type > &other)
typename std::vector< type >::const_iterator const_iterator
void reserve(const std::size_t &newSize)
void push_back(const type &elmt)
typename std::vector< type >::reverse_iterator riterator
const_riterator crbegin() const
T begin(std::pair< T, T > &p)