ATLAS Offline Software
|
DataVector
using a custom allocator for the elements.
More...
#include <DataVectorWithAlloc.h>
Classes | |
class | ContainerUniquePtr |
Helper for unique_ptr conversions. More... | |
class | HeapDeleter |
Internal helper to delete vector elements. More... | |
class | Ptr |
unique_ptr holding an element for this vector. More... | |
class | UPDeleter |
Internal helper to serve as a deleter for our unique_ptr class. More... | |
Public Types | |
typedef DV::size_type | size_type |
Basic types, forwarded from the base. More... | |
typedef DV::difference_type | difference_type |
typedef DV::allocator_type | allocator_type |
typedef DV::base_value_type | base_value_type |
typedef DV::BaseContainer | BaseContainer |
typedef DV::DVL_BASE | DVL_BASE |
typedef DV::const_iterator | const_iterator |
typedef DV::const_reverse_iterator | const_reverse_iterator |
typedef DV::value_type | value_type |
typedef DV::const_value_type | const_value_type |
typedef DV::reference | reference |
typedef DV::const_reference | const_reference |
typedef DV::pointer | pointer |
typedef DV::const_pointer | const_pointer |
typedef ALLOC | elt_allocator_type |
Type of the allocator use for vector elements. More... | |
typedef DataVector< base_value_type > | base_data_vector |
typedef DataModel_detail::ElementProxy< DataVectorWithAlloc > | ElementProxy |
This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership. More... | |
typedef DataModel_detail::iterator< DataVectorWithAlloc > | iterator |
The iterator for this type. More... | |
typedef std::reverse_iterator< iterator > | reverse_iterator |
Standard reverse_iterator . More... | |
typedef boost::true_type | isSequence |
Public Member Functions | |
Constructors, destructors, assignment. | |
DataVectorWithAlloc (elt_allocator_type &&eltAlloc=elt_allocator_type()) | |
Default constructor. More... | |
DataVectorWithAlloc (size_type n, elt_allocator_type &&eltAlloc=elt_allocator_type()) | |
Sized constructor. More... | |
DataVectorWithAlloc (const DataVectorWithAlloc &)=delete | |
DataVectorWithAlloc & | operator= (const DataVectorWithAlloc &rhs)=delete |
DataVectorWithAlloc (DataVectorWithAlloc &&rhs) | |
Move constructor. More... | |
DataVectorWithAlloc & | operator= (DataVectorWithAlloc &&rhs) |
Move assignment. More... | |
virtual | ~DataVectorWithAlloc () |
Destructor. More... | |
const elt_allocator_type & | elt_allocator () const |
Return the underlying allocator. More... | |
elt_allocator_type & | elt_allocator () |
Return the underlying allocator. More... | |
Size and capacity. | |
void | reserve (size_type n) |
Attempt to preallocate enough memory for a specified number of elements. More... | |
void | shrink_to_fit () |
Change the vector capacity to match the current size. More... | |
Element access. | |
ElementProxy | operator[] (size_type n) |
Access an element, as an lvalue. More... | |
ElementProxy | at (size_type n) |
Access an element, as an lvalue. More... | |
ElementProxy | front () |
Access the first element in the collection as an lvalue. More... | |
ElementProxy | back () |
Access the last element in the collection as an lvalue. More... | |
Iterator creation. | |
iterator | begin () noexcept |
Return an iterator pointing at the beginning of the collection. More... | |
iterator | end () noexcept |
Return an iterator pointing past the end of the collection. More... | |
reverse_iterator | rbegin () noexcept |
Return a reverse_iterator pointing past the end of the collection. More... | |
reverse_iterator | rend () noexcept |
Return a reverse_iterator pointing at the beginning of the collection. More... | |
Insertion operations. | |
value_type | push_back (Ptr pElem) |
Add an element to the end of the collection. More... | |
value_type | emplace_back (Ptr pElem) |
Add an element to the end of the collection. More... | |
iterator | insert (iterator position, Ptr pElem) |
Add a new element to the collection. More... | |
iterator | emplace (iterator position, Ptr pElem) |
Add a new element to the collection. More... | |
Erasure operations. | |
iterator | erase (iterator position) |
Remove element at a given position. More... | |
iterator | erase (iterator first, iterator last) |
Remove a range of elements. More... | |
void | clear () |
Erase all the elements in the collection. More... | |
Relational operators. | |
bool | operator< (const DataVectorWithAlloc &b) const |
Vector ordering relation. More... | |
bool | operator> (const DataVectorWithAlloc &b) const |
Based on operator<. More... | |
bool | operator<= (const DataVectorWithAlloc &b) const |
Based on operator<. More... | |
bool | operator>= (const DataVectorWithAlloc &b) const |
Based on operator<. More... | |
bool | operator== (const DataVectorWithAlloc &b) const |
Vector equality comparison. More... | |
bool | operator!= (const DataVectorWithAlloc &b) const |
Based on operator==. More... | |
Static Public Attributes | |
static const bool | has_virtual = DV::has_virtual |
This needs to be forwarded from the base as well. More... | |
static constexpr bool | must_own = true |
If true, then this type must own its contents. More... | |
Smart pointer. | |
using | unique_type = Ptr |
static ContainerUniquePtr | make_unique () |
Helper for unique_ptr conversions. More... | |
Swap and sort. | |
static void | iter_swap (iterator a, iterator b) |
Swap the referents of two DataVector iterators. More... | |
void | swap (DataVectorWithAlloc &rhs) |
Swap this collection with another. More... | |
Non-standard operations. | |
static const DataVectorWithAlloc * | fromDataVector (const DV *dv) |
Cast from a DataVector to a DataVectorWithAlloc . More... | |
void | swapElement (size_type index, Ptr newElem, Ptr &oldElem) |
Swap one element out of the container. More... | |
void | swapElement (iterator pos, Ptr newElem, Ptr &oldElem) |
Swap one element out of the container. More... | |
const DV * | asDataVector () const |
Return a pointer to this object, as a const DataVector . More... | |
void | resortAux (iterator beg, iterator end) |
Reset indices / reorder aux data after elements have been permuted. More... | |
const SG::AuxVectorBase & | auxbase () const |
Convert to AuxVectorBase . More... | |
template<class... Args> | |
Ptr | allocate (Args &&... args) |
Allocate a new vector element. More... | |
Private helpers. | |
class | DataModel_detail::ElementProxy< DataVectorWithAlloc > |
void | test2_assignelement1a () |
elt_allocator_type * | m_heap |
Non-owning pointer to the heap. More... | |
void | assignElement (typename BaseContainer::iterator pos, Ptr newElem) |
Handle element assignment. More... | |
iterator | to_my_iterator (typename DV::iterator it) |
Convert an iterator of the base DataVector to a DataVectorWithAlloc::iterator . More... | |
ElementProxy | to_element_proxy (typename BaseContainer::iterator i) |
Convert an iterator of the base vector to an ElementProxy for the DataVectorWithAlloc . More... | |
static DV::iterator | to_base_iterator (iterator it) |
Convert a DataVectorWithAlloc::iterator to an iterator of the base DataVector . More... | |
DataVector
using a custom allocator for the elements.
The ALLOC
argument defaulta to ArenaHeapSTLAllocator
(see DataVectorWithAllocFwd.h).
Definition at line 65 of file DataVectorWithAlloc.h.
typedef DV::allocator_type DataVectorWithAlloc< DV, ALLOC >::allocator_type |
Definition at line 72 of file DataVectorWithAlloc.h.
typedef DataVector<base_value_type> DataVectorWithAlloc< DV, ALLOC >::base_data_vector |
Definition at line 89 of file DataVectorWithAlloc.h.
typedef DV::base_value_type DataVectorWithAlloc< DV, ALLOC >::base_value_type |
Definition at line 73 of file DataVectorWithAlloc.h.
typedef DV::BaseContainer DataVectorWithAlloc< DV, ALLOC >::BaseContainer |
Definition at line 74 of file DataVectorWithAlloc.h.
typedef DV::const_iterator DataVectorWithAlloc< DV, ALLOC >::const_iterator |
Definition at line 76 of file DataVectorWithAlloc.h.
typedef DV::const_pointer DataVectorWithAlloc< DV, ALLOC >::const_pointer |
Definition at line 83 of file DataVectorWithAlloc.h.
typedef DV::const_reference DataVectorWithAlloc< DV, ALLOC >::const_reference |
Definition at line 81 of file DataVectorWithAlloc.h.
typedef DV::const_reverse_iterator DataVectorWithAlloc< DV, ALLOC >::const_reverse_iterator |
Definition at line 77 of file DataVectorWithAlloc.h.
typedef DV::const_value_type DataVectorWithAlloc< DV, ALLOC >::const_value_type |
Definition at line 79 of file DataVectorWithAlloc.h.
typedef DV::difference_type DataVectorWithAlloc< DV, ALLOC >::difference_type |
Definition at line 71 of file DataVectorWithAlloc.h.
typedef DV::DVL_BASE DataVectorWithAlloc< DV, ALLOC >::DVL_BASE |
Definition at line 75 of file DataVectorWithAlloc.h.
typedef DataModel_detail::ElementProxy<DataVectorWithAlloc> DataVectorWithAlloc< DV, ALLOC >::ElementProxy |
This type is used to proxy lvalue accesses to DataVector
elements, in order to handle ownership.
Definition at line 97 of file DataVectorWithAlloc.h.
typedef ALLOC DataVectorWithAlloc< DV, ALLOC >::elt_allocator_type |
Type of the allocator use for vector elements.
Definition at line 86 of file DataVectorWithAlloc.h.
typedef boost::true_type DataVectorWithAlloc< DV, ALLOC >::isSequence |
Definition at line 107 of file DataVectorWithAlloc.h.
typedef DataModel_detail::iterator<DataVectorWithAlloc> DataVectorWithAlloc< DV, ALLOC >::iterator |
The iterator for this type.
Definition at line 100 of file DataVectorWithAlloc.h.
typedef DV::pointer DataVectorWithAlloc< DV, ALLOC >::pointer |
Definition at line 82 of file DataVectorWithAlloc.h.
typedef DV::reference DataVectorWithAlloc< DV, ALLOC >::reference |
Definition at line 80 of file DataVectorWithAlloc.h.
typedef std::reverse_iterator<iterator> DataVectorWithAlloc< DV, ALLOC >::reverse_iterator |
Standard reverse_iterator
.
Note that lvalue references here will yield an ElementProxy
, not a reference
.
Definition at line 105 of file DataVectorWithAlloc.h.
typedef DV::size_type DataVectorWithAlloc< DV, ALLOC >::size_type |
Basic types, forwarded from the base.
Definition at line 70 of file DataVectorWithAlloc.h.
using DataVectorWithAlloc< DV, ALLOC >::unique_type = Ptr |
Definition at line 215 of file DataVectorWithAlloc.h.
typedef DV::value_type DataVectorWithAlloc< DV, ALLOC >::value_type |
Definition at line 78 of file DataVectorWithAlloc.h.
|
explicit |
Default constructor.
eltAlloc | The element allocator. |
|
explicit |
Sized constructor.
n | The size of the container. |
eltAlloc | The element allocator. |
Note that unlike the standard vector constructor, you can't specify an initial value here. The container will be initialized with 0's.
|
delete |
DataVectorWithAlloc< DV, ALLOC >::DataVectorWithAlloc | ( | DataVectorWithAlloc< DV, ALLOC > && | rhs | ) |
Move constructor.
rhs | The container from which to move. |
Any auxiliary data will be moved along with the container contents.
The existing allocator is moved. rhs
will be left with a new, default-initialized, allocator.
|
virtual |
Destructor.
Ptr DataVectorWithAlloc< DV, ALLOC >::allocate | ( | Args &&... | args | ) |
Allocate a new vector element.
Arguments will be forwarded to the element constructor.
const DV* DataVectorWithAlloc< DV, ALLOC >::asDataVector | ( | ) | const |
Return a pointer to this object, as a const DataVector
.
|
private |
Handle element assignment.
pos | Position in the container to assign. |
newElem | The new element to assign. |
Auxiliary data are copied if appropriate.
ElementProxy DataVectorWithAlloc< DV, ALLOC >::at | ( | size_type | n | ) |
Access an element, as an lvalue.
n | Array index to access. |
Will raise std::out_of_range
if the index is out-of-bounds. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
const SG::AuxVectorBase& DataVectorWithAlloc< DV, ALLOC >::auxbase | ( | ) | const |
Convert to AuxVectorBase
.
Needed to get @x AuxVectorBase from a ConstDataVector
. Present in DataVector
as well for consistency.
ElementProxy DataVectorWithAlloc< DV, ALLOC >::back | ( | ) |
Access the last element in the collection as an lvalue.
No checking is done to ensure that the container is not empty. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
|
noexcept |
Return an iterator
pointing at the beginning of the collection.
iterator
.Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
void DataVectorWithAlloc< DV, ALLOC >::clear | ( | ) |
Erase all the elements in the collection.
The removed elements will be deleted.
elt_allocator_type& DataVectorWithAlloc< DV, ALLOC >::elt_allocator | ( | ) |
Return the underlying allocator.
const elt_allocator_type& DataVectorWithAlloc< DV, ALLOC >::elt_allocator | ( | ) | const |
Return the underlying allocator.
iterator DataVectorWithAlloc< DV, ALLOC >::emplace | ( | iterator | position, |
Ptr | pElem | ||
) |
Add a new element to the collection.
position | Iterator before which the element will be added. |
pElem | The element to add to the collection. |
Note: this method may only be called using the most derived DataVector
in the hierarchy.
For DataVector
, this is just the same as insert
. It's included just for interface compatibility with std::vector
.
value_type DataVectorWithAlloc< DV, ALLOC >::emplace_back | ( | Ptr | pElem | ) |
Add an element to the end of the collection.
pElem | The element to add to the collection. |
Note: this method may only be called using the most derived DataVector
in the hierarchy.
For DataVector
, this is like the same as push_back
, and it returns the pushed element. It's included just for interface compatibility with std::vector
.
|
noexcept |
Return an iterator
pointing past the end of the collection.
iterator
.Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
iterator DataVectorWithAlloc< DV, ALLOC >::erase | ( | iterator | first, |
iterator | last | ||
) |
Remove a range of elements.
first | Iterator pointing to the first element to be removed. |
last | Iterator pointing one past the last element to be removed. |
end()
).The removed elements will be deleted.
iterator DataVectorWithAlloc< DV, ALLOC >::erase | ( | iterator | position | ) |
Remove element at a given position.
position | Iterator pointing to the element to be removed. |
end()
).The pointed-to element will be deleted.
|
static |
Cast from a DataVector
to a DataVectorWithAlloc
.
dv | Pointer to object to cast. |
Return DV
cast to a DataVectorWithAlloc
.
ElementProxy DataVectorWithAlloc< DV, ALLOC >::front | ( | ) |
Access the first element in the collection as an lvalue.
No checking is done to ensure that the container is not empty. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
iterator DataVectorWithAlloc< DV, ALLOC >::insert | ( | iterator | position, |
Ptr | pElem | ||
) |
Add a new element to the collection.
position | Iterator before which the element will be added. |
pElem | The element to add to the collection. |
Note: this method may only be called using the most derived DataVector
in the hierarchy.
|
static |
Swap the referents of two DataVector
iterators.
a | The first iterator for the swap. |
b | The second iterator for the swap. |
The iterators must both refer to the same container.
|
inlinestatic |
Helper for unique_ptr conversions.
If we do
we may later want to convert this to a std::unique_ptr<const DV>. We can do this via asDataVector
, but actually doing that is a bit awkward. To help with this, we introduce the type ContainerUniquePtr
, made with the static method here, that supports an implicit move conversion to std::unique_ptr<const DV>.
Definition at line 248 of file DataVectorWithAlloc.h.
bool DataVectorWithAlloc< DV, ALLOC >::operator!= | ( | const DataVectorWithAlloc< DV, ALLOC > & | b | ) | const |
Based on operator==.
bool DataVectorWithAlloc< DV, ALLOC >::operator< | ( | const DataVectorWithAlloc< DV, ALLOC > & | b | ) | const |
Vector ordering relation.
b | A DataVectorWithAlloc of the same type as *this. |
This is a total ordering relation. It is linear in the size of the vectors. Comparisons are done on the pointer values of the elements.
See std::lexicographical_compare()
for how the determination is made.
bool DataVectorWithAlloc< DV, ALLOC >::operator<= | ( | const DataVectorWithAlloc< DV, ALLOC > & | b | ) | const |
Based on operator<.
|
delete |
DataVectorWithAlloc& DataVectorWithAlloc< DV, ALLOC >::operator= | ( | DataVectorWithAlloc< DV, ALLOC > && | rhs | ) |
Move assignment.
rhs | The container from which to move. |
Any auxiliary data will be moved along with the container contents.
The existing allocator is moved. rhs
will be left with a new, default-initialized, allocator.
bool DataVectorWithAlloc< DV, ALLOC >::operator== | ( | const DataVectorWithAlloc< DV, ALLOC > & | b | ) | const |
Vector equality comparison.
b | A DataVectorWithAlloc of the same type as *this. |
This is an equivalence relation. It is linear in the size of the vectors. Vectors are considered equivalent if their sizes are equal, and if corresponding elements compare equal.
bool DataVectorWithAlloc< DV, ALLOC >::operator> | ( | const DataVectorWithAlloc< DV, ALLOC > & | b | ) | const |
Based on operator<.
bool DataVectorWithAlloc< DV, ALLOC >::operator>= | ( | const DataVectorWithAlloc< DV, ALLOC > & | b | ) | const |
Based on operator<.
ElementProxy DataVectorWithAlloc< DV, ALLOC >::operator[] | ( | size_type | n | ) |
Access an element, as an lvalue.
n | Array index to access. |
No bounds checking is done. Note that we return a proxy object rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
value_type DataVectorWithAlloc< DV, ALLOC >::push_back | ( | Ptr | pElem | ) |
Add an element to the end of the collection.
pElem | The element to add to the collection. |
Note: this method may only be called using the most derived DataVector
in the hierarchy.
Returns the pushed pointer.
|
noexcept |
Return a reverse_iterator
pointing past the end of the collection.
reverse_iterator
.Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
|
noexcept |
Return a reverse_iterator
pointing at the beginning of the collection.
reverse_iterator
.Note that dereferencing the iterator will yield a proxy rather than a reference; the proxy will handle deleting an owned element if it's assigned to.
void DataVectorWithAlloc< DV, ALLOC >::reserve | ( | size_type | n | ) |
Attempt to preallocate enough memory for a specified number of elements.
n | Number of elements required. |
void DataVectorWithAlloc< DV, ALLOC >::resortAux | ( | iterator | beg, |
iterator | end | ||
) |
Reset indices / reorder aux data after elements have been permuted.
beg | Start of the range of elements to process. |
end | End of the range of elements to process. |
void DataVectorWithAlloc< DV, ALLOC >::shrink_to_fit | ( | ) |
Change the vector capacity to match the current size.
Note: this does not affect auxiliary data.
void DataVectorWithAlloc< DV, ALLOC >::swap | ( | DataVectorWithAlloc< DV, ALLOC > & | rhs | ) |
Swap this collection with another.
rhs | The collection with which to swap. |
Ownership is swapped along with the collection content.
Note: this method may only be called using the most-derived DataVector
in the hierarchy. The rhs must also be referenced using the most-derived DataVector
.
void DataVectorWithAlloc< DV, ALLOC >::swapElement | ( | iterator | pos, |
Ptr | newElem, | ||
Ptr & | oldElem | ||
) |
Swap one element out of the container.
pos | The element in the container to swap. |
newElem | New element to put in the container. May be 0. |
oldElem | Reference to receive the element removed from the container. |
Reference oldElem is initialized with element pos of the collection (no bounds checking). Then element index is set to newElem
.
Note: this method may only be called using the most derived DataList
in the hierarchy.
void DataVectorWithAlloc< DV, ALLOC >::swapElement | ( | size_type | index, |
Ptr | newElem, | ||
Ptr & | oldElem | ||
) |
Swap one element out of the container.
index | Index of the element in the container to swap. |
newElem | New element to put in the container. May be 0. |
oldElem | Reference to receive the element removed from the container. |
Reference oldElem is initialized with element index of the collection (no bounds checking). Then element index is set to newElem
.
Note: this method may only be called using the most derived DataVector
in the hierarchy.
|
staticprivate |
Convert a DataVectorWithAlloc::iterator
to an iterator of the base DataVector
.
it | The DataVectorWithAlloc::iterator to convert. |
|
private |
Convert an iterator of the base vector
to an ElementProxy
for the DataVectorWithAlloc
.
it | The base vector iterator to convert. |
|
private |
Convert an iterator of the base DataVector
to a DataVectorWithAlloc::iterator
.
it | The base DataVector iterator to convert. |
|
friend |
Definition at line 705 of file DataVectorWithAlloc.h.
|
friend |
|
static |
This needs to be forwarded from the base as well.
Definition at line 93 of file DataVectorWithAlloc.h.
|
private |
Non-owning pointer to the heap.
Definition at line 778 of file DataVectorWithAlloc.h.
|
staticconstexpr |
If true, then this type must own its contents.
Definition at line 110 of file DataVectorWithAlloc.h.