How to prepend an element to TClonesArray

Dear ROOT developers and users,

Is there any way not to append but to prepend an element to TClonesArray ?


I do not understand your question. When creating an object in the TClonesArray, you can specify directly the place where to create it
new (loc) MyObject(…)
where loc is the array index.


Hi Rene,
Thank you for the reply.

What I want to do is to add a new element to the top of TClonesArray
like std::vector::push_front method does
so that last added element can be accessed with index = 0.
Is it allowed to start adding elements from non-zero index like

TClonesArray a("MyObject");
for (int i = n - 1; i >= 0; --i)
  new (a[i]) MyObject(..);

Even if this is allowed, the problem is that usually the number of elements(n) is not known in advance.