1 #ifndef DataFormats_Common_View_h
2 #define DataFormats_Common_View_h
23 #include "boost/iterator/indirect_iterator.hpp"
70 class View :
public ViewBase {
71 typedef std::vector<T const*>
seq_t;
81 typedef boost::indirect_iterator<typename seq_t::const_iterator>
const_iterator;
97 View(std::vector<void const*>
const& pointers,
124 std::vector<Ptr<value_type> >
const&
ptrs()
const;
139 return refs_.product();
146 mutable std::vector<Ptr<value_type> >
vPtrs_;
153 template<
typename T>
bool operator< (View<T>
const&,
View<T> const&);
154 template<
typename T>
bool operator<=(View<T>
const&,
View<T> const&);
181 if(helpers.get() != 0) {
182 assert(numElements == helpers->size());
184 items_.reserve(numElements);
185 ptrs_.reserve(refs_.size());
187 void const*
p = pointers[
i];
188 items_.push_back(static_cast<pointer>(p));
190 ptrs_.push_back(Ptr<T>(helpers->id(),
static_cast<T const*
>(
p), helpers->keyForIndex(
i)));
191 }
else if(helpers->productGetter() != 0) {
192 ptrs_.push_back(Ptr<T>(helpers->id(), helpers->keyForIndex(
i), helpers->productGetter()));
194 ptrs_.push_back(Ptr<T>(helpers->id(), 0, helpers->keyForIndex(
i)));
211 items_.swap(other.items_);
212 refs_.swap(other.refs_);
213 ptrs_.swap(other.ptrs_);
219 View<T>::capacity()
const {
220 return items_.capacity();
225 typename View<T>::const_iterator
227 return items_.begin();
232 typename View<T>::const_iterator
239 typename View<T>::const_reverse_iterator
240 View<T>::rbegin()
const {
241 return items_.rbegin();
246 typename View<T>::const_reverse_iterator
247 View<T>::rend()
const {
248 return items_.rend();
255 return items_.size();
261 View<T>::max_size()
const {
262 return items_.max_size();
269 return items_.empty();
274 typename View<T>::const_reference
276 return *items_.at(pos);
281 typename View<T>::const_reference
298 return Ptr<T>(ref.id(), (ref.isAvailable() ? ref.get(): 0), ref.key());
303 std::vector<Ptr<T> >
const&
304 View<T>::ptrs()
const {
306 if(vPtrs_.size()!=ptrs_.size()) {
307 vPtrs_.reserve(ptrs_.size());
308 std::copy(ptrs_.begin(),ptrs_.end(),std::back_inserter(vPtrs_));
316 typename View<T>::const_reference
318 return *items_.front();
323 typename View<T>::const_reference
325 return *items_.back();
331 View<T>::pop_back() {
338 View<T>::id()
const {
344 View<T>::productGetter()
const {
345 return refs_.productGetter();
353 output.items_.resize(std::distance(first, last));
355 output.items_[i] = first;
360 View<T>::doClone()
const {
361 return new View(*
this);
367 View<T>::operator=(View<T>
const& rhs) {
378 lhs.size() == rhs.size() &&
379 std::equal(lhs.begin(), lhs.end(), rhs.begin());
386 return !(lhs == rhs);
392 operator<(View<T>
const& lhs,
View<T> const& rhs) {
393 return std::lexicographical_compare(lhs.begin(), lhs.end(),
394 rhs.begin(), rhs.end());
400 operator<=(View<T>
const& lhs,
View<T> const& rhs) {
void swap(ora::Record &rh, ora::Record &lh)
const_reverse_iterator rbegin() const
EDProductGetter const * productGetter() const
RefToBaseVector< T > refs_
virtual ViewBase * doClone() const =0
Ptr< value_type > ptrAt(size_type i) const
const_reference back() const
std::vector< T const * > seq_t
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
size_type max_size() const
seq_t::difference_type difference_type
bool equal(const T &first, const T &second)
RefToBase< value_type > refAt(size_type i) const
bool operator>=(View< T > const &, View< T > const &)
const_iterator begin() const
View & operator=(View const &rhs)
std::vector< Ptr< value_type > > vPtrs_
const_reference operator[](size_type pos) const
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
bool operator>(l1t::Jet &a, l1t::Jet &b)
bool operator>(View< T > const &, View< T > const &)
T operator[](int i) const
const_reverse_iterator rend() const
size_type capacity() const
ViewBase & operator=(ViewBase const &)
std::shared_ptr< reftobase::RefVectorHolderBase > helper_vector_ptr
std::vector< Ptr< value_type > > const & ptrs() const
static void fill_from_range(T *first, T *last, View &output)
boost::indirect_iterator< typename seq_t::const_reverse_iterator > const_reverse_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
void const * product() const
const_reference at(size_type pos) const
const_iterator end() const
const_reference front() const
T first(std::pair< T, U > const &p)
T const & const_reference
tuple size
Write out results.
ViewBase * doClone() const