Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
art::PtrVector< T > Class Template Reference

#include <fwd.h>

Inheritance diagram for art::PtrVector< T >:
art::PtrVectorBase

Public Types

using value_type = typename data_t::value_type
 
using allocator_type = typename data_t::allocator_type
 
using reference = typename data_t::reference
 
using const_reference = typename data_t::const_reference
 
using pointer = typename data_t::pointer
 
using const_pointer = typename data_t::const_pointer
 
using iterator = typename data_t::iterator
 
using const_iterator = typename data_t::const_iterator
 
using reverse_iterator = typename data_t::reverse_iterator
 
using const_reverse_iterator = typename data_t::const_reverse_iterator
 
using difference_type = typename data_t::difference_type
 
using size_type = typename data_t::size_type
 
- Public Types inherited from art::PtrVectorBase
using key_type = unsigned long
 
using indices_t = std::vector< key_type >
 
using size_type = indices_t::size_type
 

Public Member Functions

 PtrVector ()
 
template<typename U >
 PtrVector (PtrVector< U > const &other)
 
template<typename U >
 PtrVector (std::initializer_list< Ptr< U >> il)
 
template<typename U >
PtrVector< T > & operator= (std::initializer_list< Ptr< U >> il)
 
template<typename U >
PtrVector< T > & operator= (PtrVector< U > const &other)&
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
size_type size () const
 
size_type max_size () const
 
void resize (size_type n)
 
size_type capacity () const
 
bool empty () const
 
void reserve (size_type n)
 
void shrink_to_fit ()
 
Ptr< T > const & operator[] (unsigned long const idx) const
 
reference at (size_type n)
 
const_reference at (size_type n) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
template<typename U >
void assign (size_type n, Ptr< U > const &p)
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 
template<typename U >
void assign (std::initializer_list< Ptr< U >> il)
 
template<typename U >
void push_back (Ptr< U > const &p)
 
template<typename... Args>
void emplace_back (Args &&...args)
 
void pop_back ()
 
template<typename U >
iterator insert (iterator position, Ptr< U > const &p)
 
template<typename U >
void insert (iterator position, size_type n, Ptr< U > const &p)
 
template<typename InputIterator >
iterator insert (const_iterator position, InputIterator first, InputIterator last)
 
iterator erase (iterator position)
 
iterator erase (iterator first, iterator last)
 
void swap (PtrVector &other)
 
void swap (key_type k1, key_type k2)
 
void clear ()
 
bool operator== (PtrVector const &other) const
 
void sort ()
 
template<class Comp >
void sort (Comp comp)
 
template<typename U >
art::PtrVector< T > & operator= (std::initializer_list< Ptr< U >> const il)
 
template<typename U >
art::PtrVector< T > & operator= (PtrVector< U > const &other)&
 
template<typename U >
art::PtrVector< T >::iterator insert (iterator const position, Ptr< U > const &p)
 
template<typename InputIterator >
auto insert (const_iterator position, InputIterator first, InputIterator last) -> iterator
 
- Public Member Functions inherited from art::PtrVectorBase
virtual ~PtrVectorBase ()=default
 
bool isNonnull () const noexcept
 
bool isNull () const noexcept
 
bool isAvailable () const
 
ProductID id () const noexcept
 
EDProductGetter const * productGetter () const noexcept
 
void setProductGetter (EDProductGetter const *) noexcept
 
template<typename T >
art::Ptr< T >::key_type key (Ptr< T > const &ptr) const noexcept
 

Static Public Member Functions

static short Class_Version ()
 

Private Types

using data_t = std::vector< Ptr< T >>
 

Private Member Functions

void fill_offsets (indices_t &indices) override
 
void fill_from_offsets (indices_t const &indices) const override
 
void zeroTransients () override
 

Private Attributes

data_t ptrs_ {}
 

Additional Inherited Members

- Protected Member Functions inherited from art::PtrVectorBase
 PtrVectorBase ()=default
 
void clear ()
 
void swap (PtrVectorBase &)
 
void updateCore (RefCore const &core)
 
bool operator== (PtrVectorBase const &) const noexcept
 

Detailed Description

template<typename T>
class art::PtrVector< T >

Definition at line 33 of file fwd.h.

Member Typedef Documentation

template<typename T>
using art::PtrVector< T >::allocator_type = typename data_t::allocator_type

Definition at line 49 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::const_iterator = typename data_t::const_iterator

Definition at line 55 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::const_pointer = typename data_t::const_pointer

Definition at line 53 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::const_reference = typename data_t::const_reference

Definition at line 51 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::const_reverse_iterator = typename data_t::const_reverse_iterator

Definition at line 57 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::data_t = std::vector<Ptr<T>>
private

Definition at line 45 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::difference_type = typename data_t::difference_type

Definition at line 58 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::iterator = typename data_t::iterator

Definition at line 54 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::pointer = typename data_t::pointer

Definition at line 52 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::reference = typename data_t::reference

Definition at line 50 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::reverse_iterator = typename data_t::reverse_iterator

Definition at line 56 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::size_type = typename data_t::size_type

Definition at line 59 of file PtrVector.h.

template<typename T>
using art::PtrVector< T >::value_type = typename data_t::value_type

Definition at line 48 of file PtrVector.h.

Constructor & Destructor Documentation

template<typename T >
art::PtrVector< T >::PtrVector ( )
inlinedefault
template<typename T >
template<typename U >
art::PtrVector< T >::PtrVector ( PtrVector< U > const &  other)
inline

Definition at line 165 of file PtrVector.h.

167 {
168  // Ensure that types are compatible.
169  static_assert(std::is_base_of_v<T, U> || std::is_base_of_v<U, T>,
170  "PtrVector: incompatible types");
171  ptrs_.reserve(other.size());
172  cet::copy_all(other, std::back_inserter(ptrs_));
173 }
PtrVectorBase()=default
auto copy_all(FwdCont &, FwdIter)
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
template<typename U >
art::PtrVector< T >::PtrVector ( std::initializer_list< Ptr< U >>  il)
inline

Definition at line 177 of file PtrVector.h.

178 {
179  static_assert(std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
180  std::is_base_of_v<U, T>,
181  "PtrVector: incompatible types");
182  ptrs_.reserve(il.size());
183  for (auto&& p : il) {
184  updateCore(p.refCore());
185  ptrs_.push_back(std::move(p));
186  }
187 }
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)

Member Function Documentation

template<typename T >
template<typename U >
void art::PtrVector< T >::assign ( size_type  n,
Ptr< U > const &  p 
)
inline

Definition at line 403 of file PtrVector.h.

404 {
405  static_assert(std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
406  std::is_base_of_v<U, T>,
407  "PtrVector: incompatible types");
409  updateCore(p.refCore());
410  ptrs_.assign(n, p);
411 }
std::void_t< T > n
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)
template<typename T >
template<typename InputIterator >
void art::PtrVector< T >::assign ( InputIterator  first,
InputIterator  last 
)
inline

Definition at line 416 of file PtrVector.h.

417 {
419  std::for_each(
420  first, last, [this](Ptr<T> const& p) { updateCore(p.refCore()); });
421  ptrs_.assign(first, last);
422 }
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)
template<typename T >
template<typename U >
void art::PtrVector< T >::assign ( std::initializer_list< Ptr< U >>  il)
inline

Definition at line 427 of file PtrVector.h.

428 {
429  assign(il.begin(), il.end());
430 }
void assign(size_type n, Ptr< U > const &p)
Definition: PtrVector.h:403
template<typename T >
auto art::PtrVector< T >::at ( size_type  n)
inline

Definition at line 359 of file PtrVector.h.

360 {
361  return ptrs_.at(n);
362 }
std::void_t< T > n
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::at ( size_type  n) const
inline

Definition at line 366 of file PtrVector.h.

367 {
368  return ptrs_.at(n);
369 }
std::void_t< T > n
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::back ( )
inline

Definition at line 387 of file PtrVector.h.

388 {
389  return ptrs_.back();
390 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::back ( ) const
inline

Definition at line 394 of file PtrVector.h.

395 {
396  return ptrs_.back();
397 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::begin ( )
inline

Definition at line 217 of file PtrVector.h.

218 {
219  return ptrs_.begin();
220 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::begin ( ) const
inline

Definition at line 224 of file PtrVector.h.

225 {
226  return ptrs_.begin();
227 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::capacity ( ) const
inline

Definition at line 323 of file PtrVector.h.

324 {
325  return ptrs_.capacity();
326 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::cbegin ( ) const
inline

Definition at line 273 of file PtrVector.h.

274 {
275  return ptrs_.cbegin();
276 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::cend ( ) const
inline

Definition at line 280 of file PtrVector.h.

281 {
282  return ptrs_.cend();
283 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T>
static short art::PtrVector< T >::Class_Version ( )
inlinestatic

Definition at line 140 of file PtrVector.h.

141  {
142  return 11;
143  }
template<typename T >
void art::PtrVector< T >::clear ( )
inline

Definition at line 533 of file PtrVector.h.

534 {
535  ptrs_.clear();
537 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::crbegin ( ) const
inline

Definition at line 287 of file PtrVector.h.

288 {
289  return ptrs_.crbegin();
290 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::crend ( ) const
inline

Definition at line 294 of file PtrVector.h.

295 {
296  return ptrs_.crend();
297 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
template<typename... Args>
void art::PtrVector< T >::emplace_back ( Args &&...  args)
inline

Definition at line 448 of file PtrVector.h.

449 {
450  Ptr<T> p{std::forward<Args>(args)...};
451  updateCore(p.refCore());
452  ptrs_.push_back(std::move(p));
453 }
static QCString args
Definition: declinfo.cpp:674
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)
template<typename T >
bool art::PtrVector< T >::empty ( ) const
inline

Definition at line 330 of file PtrVector.h.

331 {
332  return ptrs_.empty();
333 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::end ( )
inline

Definition at line 231 of file PtrVector.h.

232 {
233  return ptrs_.end();
234 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::end ( ) const
inline

Definition at line 238 of file PtrVector.h.

239 {
240  return ptrs_.end();
241 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::erase ( iterator  position)
inline

Definition at line 504 of file PtrVector.h.

505 {
506  return ptrs_.erase(position);
507 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::erase ( iterator  first,
iterator  last 
)
inline

Definition at line 511 of file PtrVector.h.

512 {
513  return ptrs_.erase(first, last);
514 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::fill_from_offsets ( indices_t const &  indices) const
overrideprivatevirtual

Implements art::PtrVectorBase.

Definition at line 575 of file PtrVector.h.

576 {
577  // Precondition: ptrs_ is expected to be empty.
578  assert(ptrs_.empty());
579  ptrs_.reserve(indices.size());
580  for (auto i : indices) {
581  ptrs_.emplace_back(id(), i, productGetter());
582  }
583 }
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
EDProductGetter const * productGetter() const noexcept
Definition: PtrVectorBase.h:86
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::fill_offsets ( indices_t indices)
overrideprivatevirtual

Implements art::PtrVectorBase.

Definition at line 563 of file PtrVector.h.

564 {
565  // Precondition: indices is expected to be empty.
566  assert(indices.empty());
567  indices.reserve(ptrs_.size());
568  for (auto const& i : ptrs_) {
569  indices.push_back(i.key());
570  }
571 }
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::front ( )
inline

Definition at line 373 of file PtrVector.h.

374 {
375  return ptrs_.front();
376 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::front ( ) const
inline

Definition at line 380 of file PtrVector.h.

381 {
382  return ptrs_.front();
383 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T>
template<typename U >
iterator art::PtrVector< T >::insert ( iterator  position,
Ptr< U > const &  p 
)
template<typename T >
template<typename U >
void art::PtrVector< T >::insert ( iterator  position,
size_type  n,
Ptr< U > const &  p 
)
inline

Definition at line 478 of file PtrVector.h.

481 {
482  // Ensure that types are compatible.
483  static_assert(std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
484  std::is_base_of_v<U, T>,
485  "PtrVector: incompatible types");
486  updateCore(p.refCore());
487  ptrs_.insert(position, n, p);
488 }
std::void_t< T > n
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)
template<typename T>
template<typename InputIterator >
iterator art::PtrVector< T >::insert ( const_iterator  position,
InputIterator  first,
InputIterator  last 
)
template<typename T>
template<typename U >
art::PtrVector<T>::iterator art::PtrVector< T >::insert ( iterator const  position,
Ptr< U > const &  p 
)
inline

Definition at line 465 of file PtrVector.h.

466 {
467  // Ensure that types are compatible.
468  static_assert(std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
469  std::is_base_of_v<U, T>,
470  "PtrVector: incompatible types");
471  updateCore(p.refCore());
472  return ptrs_.insert(position, p);
473 }
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)
template<typename T>
template<typename InputIterator >
auto art::PtrVector< T >::insert ( const_iterator  position,
InputIterator  first,
InputIterator  last 
) -> iterator
inline

Definition at line 493 of file PtrVector.h.

496 {
497  std::for_each(
498  first, last, [this](Ptr<T> const& p) { updateCore(p.refCore()); });
499  return ptrs_.insert(position, first, last);
500 }
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)
template<typename T >
auto art::PtrVector< T >::max_size ( ) const
inline

Definition at line 309 of file PtrVector.h.

310 {
311  return ptrs_.max_size();
312 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T>
template<typename U >
PtrVector<T>& art::PtrVector< T >::operator= ( std::initializer_list< Ptr< U >>  il)
template<typename T>
template<typename U >
PtrVector<T>& art::PtrVector< T >::operator= ( PtrVector< U > const &  other)
template<typename T>
template<typename U >
art::PtrVector<T>& art::PtrVector< T >::operator= ( std::initializer_list< Ptr< U >> const  il)
inline

Definition at line 192 of file PtrVector.h.

193 {
194  static_assert(std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
195  std::is_base_of_v<U, T>,
196  "PtrVector: incompatible types");
197  assign(il);
198  return *this;
199 }
void assign(size_type n, Ptr< U > const &p)
Definition: PtrVector.h:403
template<typename T>
template<typename U >
art::PtrVector<T>& art::PtrVector< T >::operator= ( PtrVector< U > const &  other)
inline

Definition at line 204 of file PtrVector.h.

205 {
206  static_assert(std::is_base_of_v<T, U> || std::is_base_of_v<U, T>,
207  "PtrVector: incompatible types");
208  PtrVectorBase::operator=(other);
209  ptrs_.clear();
210  cet::copy_all(other, std::back_inserter(ptrs_));
211  return *this;
212 }
auto copy_all(FwdCont &, FwdIter)
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
bool art::PtrVector< T >::operator== ( PtrVector< T > const &  other) const
inline

Definition at line 541 of file PtrVector.h.

542 {
543  return ptrs_ == other.ptrs_ && PtrVectorBase::operator==(other);
544 }
bool operator==(PtrVectorBase const &) const noexcept
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
art::Ptr< T > const & art::PtrVector< T >::operator[] ( unsigned long const  idx) const
inline

Definition at line 351 of file PtrVector.h.

353 {
354  return *(begin() + idx);
355 }
iterator begin()
Definition: PtrVector.h:217
template<typename T >
void art::PtrVector< T >::pop_back ( )
inline

Definition at line 457 of file PtrVector.h.

458 {
459  ptrs_.pop_back();
460 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
template<typename U >
void art::PtrVector< T >::push_back ( Ptr< U > const &  p)
inline

Definition at line 435 of file PtrVector.h.

436 {
437  // Ensure that types are compatible.
438  static_assert(std::is_same_v<T, U> || std::is_base_of_v<T, U> ||
439  std::is_base_of_v<U, T>,
440  "PtrVector: incompatible types");
441  updateCore(p.refCore());
442  ptrs_.push_back(p);
443 }
p
Definition: test.py:223
data_t ptrs_
Definition: PtrVector.h:151
void updateCore(RefCore const &core)
template<typename T >
auto art::PtrVector< T >::rbegin ( )
inline

Definition at line 245 of file PtrVector.h.

246 {
247  return ptrs_.rbegin();
248 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::rbegin ( ) const
inline

Definition at line 252 of file PtrVector.h.

253 {
254  return ptrs_.rbegin();
255 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::rend ( )
inline

Definition at line 259 of file PtrVector.h.

260 {
261  return ptrs_.rend();
262 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::rend ( ) const
inline

Definition at line 266 of file PtrVector.h.

267 {
268  return ptrs_.rend();
269 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::reserve ( size_type  n)
inline

Definition at line 337 of file PtrVector.h.

338 {
339  ptrs_.reserve(n);
340 }
std::void_t< T > n
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::resize ( size_type  n)
inline

Definition at line 316 of file PtrVector.h.

317 {
318  ptrs_.resize(n);
319 }
std::void_t< T > n
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::shrink_to_fit ( )
inline

Definition at line 344 of file PtrVector.h.

345 {
346  ptrs_.shrink_to_fit();
347 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
auto art::PtrVector< T >::size ( ) const
inline

Definition at line 302 of file PtrVector.h.

303 {
304  return ptrs_.size();
305 }
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::sort ( )
inline

Definition at line 548 of file PtrVector.h.

549 {
550  sort(std::less<T>{});
551 }
template<typename T >
template<class Comp >
void art::PtrVector< T >::sort ( Comp  comp)
inline

Definition at line 556 of file PtrVector.h.

557 {
558  cet::sort_all(ptrs_, ComparePtrs{comp});
559 }
void sort_all(RandCont &)
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::swap ( PtrVector< T > &  other)
inline

Definition at line 518 of file PtrVector.h.

519 {
520  ptrs_.swap(other.ptrs_);
522 }
void swap(PtrVectorBase &)
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::swap ( key_type  k1,
key_type  k2 
)
inline

Definition at line 526 of file PtrVector.h.

527 {
528  std::swap(ptrs_[k1], ptrs_[k2]);
529 }
void swap(PtrVector< T > &, PtrVector< T > &)
Definition: PtrVector.h:595
data_t ptrs_
Definition: PtrVector.h:151
template<typename T >
void art::PtrVector< T >::zeroTransients ( )
inlineoverrideprivatevirtual

Implements art::PtrVectorBase.

Definition at line 587 of file PtrVector.h.

588 {
589  data_t tmp;
590  ptrs_.swap(tmp);
591 }
std::vector< Ptr< T >> data_t
Definition: PtrVector.h:45
string tmp
Definition: languages.py:63
data_t ptrs_
Definition: PtrVector.h:151

Member Data Documentation

template<typename T>
data_t art::PtrVector< T >::ptrs_ {}
mutableprivate

Definition at line 151 of file PtrVector.h.


The documentation for this class was generated from the following files: