1 #ifndef canvas_Persistency_Common_PtrVector_h 2 #define canvas_Persistency_Common_PtrVector_h 13 #include "cetlib/compiler_macros.h" 15 #include <initializer_list> 19 #if GCC_IS_AT_LEAST(4, 9, 0) || CLANG_IS_AT_LEAST(3, 5, 0) 20 #define PV_INSERT_POSITION_TYPE const_iterator 22 #define PV_INSERT_POSITION_TYPE iterator 30 void swap(PtrVector<T>&, PtrVector<T>&);
32 template <
typename COMP>
81 const_iterator
begin()
const;
83 const_iterator
end()
const;
84 reverse_iterator rbegin();
85 const_reverse_iterator rbegin()
const;
86 reverse_iterator rend();
87 const_reverse_iterator rend()
const;
89 const_iterator cbegin()
const;
90 const_iterator cend()
const;
91 const_reverse_iterator crbegin()
const;
92 const_reverse_iterator crend()
const;
95 size_type size()
const;
96 size_type max_size()
const;
97 void resize(size_type
n);
98 size_type capacity()
const;
100 void reserve(size_type
n);
101 void shrink_to_fit();
104 Ptr<T> const& operator[](
unsigned long const idx)
const;
105 reference at(size_type
n);
106 const_reference at(size_type
n)
const;
108 const_reference front()
const;
110 const_reference back()
const;
114 template <
typename U>
115 void assign(size_type
n,
Ptr<U> const& p);
116 template <
class InputIterator>
117 void assign(InputIterator first, InputIterator last);
118 template <
typename U>
119 void assign(std::initializer_list<
Ptr<U>> il);
120 template <
typename U>
121 void push_back(
Ptr<U> const& p);
123 template <
typename U>
124 iterator insert(iterator position,
Ptr<U> const& p);
125 template <
typename U>
126 void insert(iterator position, size_type
n,
Ptr<U> const& p);
127 template <
typename InputIterator>
131 iterator erase(iterator position);
132 iterator erase(iterator first, iterator last);
141 template <
class COMP>
142 void sort(COMP comp);
151 void fill_from_offsets(
indices_t const& indices)
const override;
152 void zeroTransients()
override;
159 #include <functional> 161 #include <type_traits> 164 template <
typename T>
168 template <
typename T>
169 template <
typename U>
175 "PtrVector: incompatible types");
177 std::copy(other.
begin(), other.
end(), std::back_inserter(
ptrs_));
180 template <
typename T>
181 template <
typename U>
187 "PtrVector: incompatible types");
188 ptrs_.reserve(il.size());
189 for (
auto&& p : il) {
191 ptrs_.push_back(std::move(p));
195 template <
typename T>
196 template <
typename U>
202 "PtrVector: incompatible types");
207 template <
typename T>
208 template <
typename U>
213 "PtrVector: incompatible types");
214 this->PtrVectorBase::operator=(
other);
221 template <
typename T>
225 return ptrs_.begin();
228 template <
typename T>
232 return ptrs_.begin();
235 template <
typename T>
242 template <
typename T>
249 template <
typename T>
253 return ptrs_.rbegin();
256 template <
typename T>
260 return ptrs_.rbegin();
263 template <
typename T>
270 template <
typename T>
277 template <
typename T>
281 return ptrs_.cbegin();
284 template <
typename T>
291 template <
typename T>
295 return ptrs_.crbegin();
298 template <
typename T>
302 return ptrs_.crend();
306 template <
typename T>
313 template <
typename T>
317 return ptrs_.max_size();
320 template <
typename T>
327 template <
typename T>
331 return ptrs_.capacity();
334 template <
typename T>
338 return ptrs_.empty();
341 template <
typename T>
348 template <
typename T>
352 ptrs_.shrink_to_fit();
356 template <
typename T>
358 unsigned long const idx)
const 360 return *(
begin() + idx);
363 template <
typename T>
370 template <
typename T>
377 template <
typename T>
381 return ptrs_.front();
384 template <
typename T>
388 return ptrs_.front();
391 template <
typename T>
398 template <
typename T>
406 template <
typename T>
407 template <
typename U>
413 "PtrVector: incompatible types");
419 template <
typename T>
420 template <
typename InputIterator>
427 ptrs_.assign(first, last);
430 template <
typename T>
431 template <
typename U>
435 assign(il.begin(), il.end());
438 template <
typename T>
439 template <
typename U>
446 "PtrVector: incompatible types");
451 template <
typename T>
458 template <
typename T>
459 template <
typename U>
466 "PtrVector: incompatible types");
468 return ptrs_.insert(position, p);
471 template <
typename T>
472 template <
typename U>
479 "PtrVector: incompatible types");
481 ptrs_.insert(position, n, p);
484 template <
typename T>
485 template <
typename InputIterator>
493 #if GCC_IS_AT_LEAST(4, 9, 0) || CLANG_IS_AT_LEAST(3, 5, 0) 495 return ptrs_.insert(position, first, last);
498 auto const orig_dist = std::distance(
ptrs_.begin(), position);
499 ptrs_.insert(position, first, last);
501 std::advance(result, orig_dist);
506 template <
typename T>
510 return ptrs_.erase(position);
513 template <
typename T>
517 return ptrs_.erase(first, last);
520 template <
typename T>
528 template <
typename T>
535 template <
typename T>
543 template <
typename T>
550 template <
typename T>
554 sort(std::less<T>());
557 template <
typename T>
558 template <
class COMP>
565 template <
typename T>
570 assert(indices.empty());
571 indices.reserve(
ptrs_.size());
572 for (
auto const& i :
ptrs_) {
573 indices.push_back(i.key());
577 template <
typename T>
582 assert(
ptrs_.empty());
583 ptrs_.reserve(indices.size());
584 for (
auto i : indices) {
589 template <
typename T>
597 template <
typename T>
604 #undef PV_INSERT_POSITION_TYPE void swap(PtrVectorBase &)
data_t::const_reference const_reference
void reserve(size_type n)
std::vector< Ptr< T > > data_t
void swap(PtrVector< T > &, PtrVector< T > &)
size_type max_size() const
bool operator()(Ptr< T > const &a, Ptr< T > const &b)
EDProductGetter const * productGetter() const
PtrVector< T > & operator=(std::initializer_list< Ptr< U >> il)
void swap(PtrVector &other)
void fill_offsets(indices_t &indices) override
iterator erase(iterator position)
const_reverse_iterator crbegin() const
reverse_iterator rbegin()
size_type capacity() const
static short Class_Version()
const_reverse_iterator crend() const
data_t::size_type size_type
data_t::value_type value_type
void fill_from_offsets(indices_t const &indices) const override
bool operator==(PtrVectorBase const &) const
void push_back(Ptr< U > const &p)
void swap(Handle< T > &a, Handle< T > &b)
RefCore const & refCore() const
data_t::difference_type difference_type
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
reference at(size_type n)
data_t::const_pointer const_pointer
const_iterator cbegin() const
data_t::iterator iterator
data_t::const_iterator const_iterator
iterator insert(iterator position, Ptr< U > const &p)
std::string value(boost::any const &)
const_iterator cend() const
void assign(size_type n, Ptr< U > const &p)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
std::vector< key_type > indices_t
data_t::reference reference
#define PV_INSERT_POSITION_TYPE
void updateCore(RefCore const &core)
data_t::reverse_iterator reverse_iterator
bool operator==(Provenance const &a, Provenance const &b)
Ptr< T > const & operator[](unsigned long const idx) const
bool operator==(PtrVector const &other) const
data_t::const_reverse_iterator const_reverse_iterator
void zeroTransients() override
data_t::allocator_type allocator_type