1 #ifndef DataFormats_Common_OwnVector_h
2 #define DataFormats_Common_OwnVector_h
11 #if defined CMS_USE_DEBUGGING_ALLOCATOR
23 template <
typename T,
typename P = ClonePolicy<T> >
26 #if defined(CMS_USE_DEBUGGING_ALLOCATOR)
27 typedef std::vector<T*, debugging_allocator<T> >
base;
29 typedef std::vector<T*>
base;
68 typename base::const_iterator
base_iter()
const {
return i; }
69 typename base::const_iterator
i;
98 iterator(
typename base::iterator
const& it) :
i(it) { }
99 typename base::iterator
i;
108 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
124 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
129 data_.shrink_to_fit();
136 template <
typename D>
void push_back(std::auto_ptr<D>
d);
139 template <
typename D>
void set(
size_t i,
D*&
d);
140 template <
typename D>
void set(
size_t i,
D*
const &
d);
141 template <
typename D>
void set(
size_t i, std::auto_ptr<D>
d);
142 void set(
size_t i, T
const& valueToCopy);
144 template <
typename D>
void insert(const_iterator
i,
D*&
d);
145 template <
typename D>
void insert(const_iterator
i,
D*
const &
d);
146 template <
typename D>
void insert(const_iterator
i, std::auto_ptr<D>
d);
147 void insert(const_iterator
i, T
const& valueToCopy);
157 iterator
erase(iterator pos);
167 std::vector<void const*>& pointers,
170 void setPtr(std::type_info
const& toType,
172 void const*& ptr)
const;
175 std::vector<unsigned long>
const& indices,
176 std::vector<void const*>& ptrs)
const;
188 return comp(*t1, *t2);
195 return Ordering<O>(
comp);
200 template<
typename T,
typename P>
204 template<
typename T,
typename P>
208 template<
typename T,
typename P>
210 size_type current = 0;
211 for (const_iterator
i = o.
begin(),
e = o.
end();
i !=
e; ++
i,++current)
215 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
216 template<
typename T,
typename P>
222 template<
typename T,
typename P>
227 template<
typename T,
typename P>
234 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
235 template<
typename T,
typename P>
243 template<
typename T,
typename P>
248 template<
typename T,
typename P>
253 template<
typename T,
typename P>
258 template<
typename T,
typename P>
263 template<
typename T,
typename P>
268 template<
typename T,
typename P>
270 return data_.empty();
273 template<
typename T,
typename P>
278 template<
typename T,
typename P>
283 template<
typename T,
typename P>
288 template<
typename T,
typename P>
298 template<
typename T,
typename P>
310 template<
typename T,
typename P>
313 data_.push_back(d.release());
317 template<
typename T,
typename P>
322 template<
typename T,
typename P>
326 if (d == data_[i])
return;
332 template<
typename T,
typename P>
336 if (d == data_[i])
return;
342 template<
typename T,
typename P>
345 if (d.get() == data_[
i])
return;
347 data_[
i] = d.release();
351 template<
typename T,
typename P>
353 if (&d == data_[i])
return;
359 template<
typename T,
typename P>
366 template<
typename T,
typename P>
373 template<
typename T,
typename P>
376 data_.insert(it.
base_iter(), d.release());
380 template<
typename T,
typename P>
387 template<
typename T,
typename P>
395 template <
typename T,
typename P>
397 return data_.back() != 0;
400 template<
typename T,
typename P>
405 "In OwnVector::back() we have intercepted an attempt to dereference a null pointer\n"
406 "Since OwnVector is allowed to contain null pointers, you much assure that the\n"
407 "pointer at the end of the collection is not null before calling back()\n"
408 "if you wish to avoid this exception.\n"
409 "Consider using OwnVector::is_back_safe()\n");
411 return *data_.back();
414 template<
typename T,
typename P>
419 "In OwnVector::back() we have intercepted an attempt to dereference a null pointer\n"
420 "Since OwnVector is allowed to contain null pointers, you much assure that the\n"
421 "pointer at the end of the collection is not null before calling back()\n"
422 "if you wish to avoid this exception.\n"
423 "Consider using OwnVector::is_back_safe()\n");
425 return *data_.back();
428 template<
typename T,
typename P>
430 return *data_.front();
433 template<
typename T,
typename P>
435 return *data_.front();
438 template<
typename T,
typename P>
440 typename base::const_iterator
b = data_.begin(),
e = data_.end();
441 for(
typename base::const_iterator
i = b;
i !=
e; ++
i)
445 template<
typename T,
typename P>
450 template<
typename T,
typename P>
456 template<
typename T,
typename P>
462 template<
typename T,
typename P>
464 typename base::iterator
b = first.
i,
e = last.
i;
465 for(
typename base::iterator
i = b;
i !=
e; ++
i)
470 template<
typename T,
typename P>
template<
typename S>
472 std::sort(data_.begin(), data_.end(),
ordering(comp));
475 template<
typename T,
typename P>
477 std::sort(data_.begin(), data_.end(),
ordering(std::less<value_type>()));
480 template<
typename T,
typename P>
482 data_.swap(other.data_);
485 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
486 template<
typename T,
typename P>
488 std::vector<void const*>& pointers,
490 size_type numElements = this->
size();
491 pointers.reserve(numElements);
492 helpers.reserve(numElements);
494 for(
typename base::const_iterator
i=data_.begin(),
e=data_.end();
i!=
e; ++
i, ++
key) {
498 "In OwnVector::fillView() we have intercepted an attempt to put a null pointer\n"
499 "into a View and that is not allowed. It is probably an error that the null\n"
500 "pointer was in the OwnVector in the first place.\n");
503 pointers.push_back(*
i);
504 helpers.emplace_back(
id,key);
510 template<
typename T,
typename P>
519 template <
typename T,
typename P>
524 std::vector<void const*>& pointers,
526 obj.
fillView(
id, pointers, helpers);
530 template <
typename T,
typename P>
538 template <
typename T,
typename P>
543 void const*& ptr)
const {
544 detail::reallySetPtr<OwnVector<T,P> >(*
this, toType,
index, ptr);
547 template <
typename T,
typename P>
551 std::type_info
const& toType,
554 obj.
setPtr(toType, index, ptr);
557 template <
typename T,
typename P>
561 std::vector<unsigned long>
const& indices,
562 std::vector<void const*>& ptrs)
const {
567 template <
typename T,
typename P>
571 std::type_info
const& toType,
572 std::vector<unsigned long>
const& indices,
573 std::vector<void const*>& ptrs) {
578 template <
typename T,
typename P>
difference_type operator-(iterator const &o) const
T const * operator->() const
iterator operator-(difference_type n) const
base::const_iterator::iterator_category iterator_category
const_iterator & operator++()
reference operator[](size_type)
bool operator()(T const *t1, T const *t2) const
void fillPtrVector(std::vector< T, A > const &obj, std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr)
iterator & operator+=(difference_type d)
T const & operator*() const
iterator & operator-=(difference_type d)
void fillView(ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) const
bool operator!=(iterator const &ci) const
bool operator==(const_iterator const &ci) const
#define CMS_CLASS_VERSION(_version_)
OwnVector< T, P > & operator=(OwnVector< T, P > const &)
void swap(Association< C > &lhs, Association< C > &rhs)
void setPtr(std::vector< T, A > const &obj, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
void reallyfillPtrVector(COLLECTION const &coll, std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr)
const_iterator operator--(int)
bool operator<(const_iterator const &o) const
reference operator[](difference_type d) const
bool operator<(iterator const &o) const
bool operator==(iterator const &ci) const
reference operator[](difference_type d) const
ptrdiff_t difference_type
auto const T2 &decltype(t1.eta()) t2
const_iterator(typename base::const_iterator const &it)
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
iterator erase(iterator pos)
void setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const
void set(size_t i, D *&d)
ptrdiff_t difference_type
void fillPtrVector(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptrs) const
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
const_iterator operator++(int)
bool is_back_safe() const
const_iterator(iterator const &it)
DecomposeProduct< arg, typename Div::arg > D
T const & const_reference
base::size_type size_type
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
double S(const TLorentzVector &, const TLorentzVector &)
base const & data() const
iterator(typename base::iterator const &it)
difference_type operator-(const_iterator const &o) const
const_iterator & operator--()
static Ordering< O > ordering(O const &comp)
iterator operator+(difference_type n) const
const_iterator & operator-=(difference_type d)
T first(std::pair< T, U > const &p)
base::const_iterator base_iter() const
void swap(OwnVector< T, P > &other)
void insert(const_iterator i, D *&d)
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
const_iterator operator+(difference_type n) const
tuple size
Write out results.
bool operator!=(const_iterator const &ci) const
const_iterator & operator+=(difference_type d)
base::iterator::iterator_category iterator_category
const_iterator operator-(difference_type n) const