ATLAS Offline Software
Loading...
Searching...
No Matches
ContainerList< T_Container > Class Template Reference

Helper class which provides a possibly dynamically growing list of containers suitable for a multi-threaded context. More...

#include <ContainerList.h>

Collaboration diagram for ContainerList< T_Container >:

Public Member Functions

 ContainerList (unsigned int expected_max_container)
 Create a container list for a certain number of containers.
std::size_t size () const
 The number of containers in this list.
T_Container & operator[] (unsigned int idx)
 Return the container with the given container index (read-write).a.
const T_Container & operator[] (unsigned int idx) const
 Return the container with the given container index (read-only).

Private Types

using T_ContainerPtr = T_Container *
using ContainerPtrList = T_ContainerPtr *

Static Private Member Functions

static std::span< T_ContainerPtrfillContainerList (unsigned int begin_idx, std::vector< T_Container > &container, std::span< T_ContainerPtr > container_list)
 Write pointers to containers in the given vector to a list starting at begin_index.

Private Attributes

T_Container * m_singleElementContainerList {}
 A container "list" which can only contain a single container.
std::span< T_ContainerPtrm_containerList
 The current container list.
std::vector< std::vector< T_Container > > m_container
 All containers.
std::vector< std::vector< T_ContainerPtr > > m_containerListHistory
 The history of the container lists where each subsequent element is an extended copy of the preceding list.

Friends

struct DynamicContainerListHelper< T_Container >

Detailed Description

template<typename T_Container>
class ContainerList< T_Container >

Helper class which provides a possibly dynamically growing list of containers suitable for a multi-threaded context.

The idea is that there is a reasonable estimate of the total number of needed containers, however if the estimate was too optimistic the list can be grown. The operation to grow the list is mutex protected.

Definition at line 21 of file ContainerList.h.

Member Typedef Documentation

◆ ContainerPtrList

template<typename T_Container>
using ContainerList< T_Container >::ContainerPtrList = T_ContainerPtr *
private

Definition at line 25 of file ContainerList.h.

◆ T_ContainerPtr

template<typename T_Container>
using ContainerList< T_Container >::T_ContainerPtr = T_Container *
private

Definition at line 24 of file ContainerList.h.

Constructor & Destructor Documentation

◆ ContainerList()

template<typename T_Container>
ContainerList< T_Container >::ContainerList ( unsigned int expected_max_container)
inline

Create a container list for a certain number of containers.

Parameters
expected_max_containerthe number of expected containers this list will have (in most cases this should rather be too large than too small). If the initial guess was too optimistic the list will be grown, which adds some computational overhead (lock congestion).

Definition at line 33 of file ContainerList.h.

34 {
35 m_container.emplace_back(expected_max_container); // create expected_max_container containers
36 // and create and populate the container list.
38 m_container.back(),
42 }
Helper class which provides a possibly dynamically growing list of containers suitable for a multi-th...
std::vector< std::vector< T_ContainerPtr > > m_containerListHistory
The history of the container lists where each subsequent element is an extended copy of the preceding...
std::span< T_ContainerPtr > m_containerList
The current container list.
static std::span< T_ContainerPtr > fillContainerList(unsigned int begin_idx, std::vector< T_Container > &container, std::span< T_ContainerPtr > container_list)
Write pointers to containers in the given vector to a list starting at begin_index.
std::vector< std::vector< T_Container > > m_container
All containers.
T_Container * m_singleElementContainerList
A container "list" which can only contain a single container.

Member Function Documentation

◆ fillContainerList()

template<typename T_Container>
std::span< T_ContainerPtr > ContainerList< T_Container >::fillContainerList ( unsigned int begin_idx,
std::vector< T_Container > & container,
std::span< T_ContainerPtr > container_list )
inlinestaticprivate

Write pointers to containers in the given vector to a list starting at begin_index.

Parameters
begin_indexthe pointer of the first element in container will be written to to container_list[begin_index] and so forth.
containera vector of new containers which are to be registered in the given container list
container_lista contiguous list of all the containers.

Definition at line 62 of file ContainerList.h.

64 {
65 unsigned int end_idx=begin_idx+container.size();
67 for (unsigned int idx=begin_idx; idx < end_idx; ++idx) {
69 }
70 return container_list;
71 }
std::size_t size() const
The number of containers in this list.

◆ operator[]() [1/2]

template<typename T_Container>
T_Container & ContainerList< T_Container >::operator[] ( unsigned int idx)
inline

Return the container with the given container index (read-write).a.

Definition at line 47 of file ContainerList.h.

47 {
49 return *(m_containerList[idx]);
50 }

◆ operator[]() [2/2]

template<typename T_Container>
const T_Container & ContainerList< T_Container >::operator[] ( unsigned int idx) const
inline

Return the container with the given container index (read-only).

Definition at line 52 of file ContainerList.h.

52 {
54 return *(m_containerList[idx]);
55 }

◆ size()

template<typename T_Container>
std::size_t ContainerList< T_Container >::size ( ) const
inline

The number of containers in this list.

Definition at line 45 of file ContainerList.h.

45{ return m_containerList.size(); }

◆ DynamicContainerListHelper< T_Container >

template<typename T_Container>
friend struct DynamicContainerListHelper< T_Container >
friend

Definition at line 1 of file ContainerList.h.

Member Data Documentation

◆ m_container

template<typename T_Container>
std::vector< std::vector<T_Container> > ContainerList< T_Container >::m_container
private

All containers.

Definition at line 80 of file ContainerList.h.

◆ m_containerList

template<typename T_Container>
std::span<T_ContainerPtr> ContainerList< T_Container >::m_containerList
private

The current container list.

Definition at line 77 of file ContainerList.h.

◆ m_containerListHistory

template<typename T_Container>
std::vector< std::vector<T_ContainerPtr> > ContainerList< T_Container >::m_containerListHistory
private

The history of the container lists where each subsequent element is an extended copy of the preceding list.

Definition at line 83 of file ContainerList.h.

◆ m_singleElementContainerList

template<typename T_Container>
T_Container* ContainerList< T_Container >::m_singleElementContainerList {}
private

A container "list" which can only contain a single container.

Definition at line 75 of file ContainerList.h.

75{};

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