All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
geo::GeoIDdataContainer< T, Mapper > Class Template Reference

Container with one element per geometry TPC. More...

#include <GeometryDataContainers.h>

Classes

struct  IDextractor
 Functor to extract an ID data member. More...
 

Public Types

using Mapper_t = Mapper
 Type of mapper between IDs and index. More...
 
using ID_t = typename Mapper_t::ID_t
 Type used as ID for this container. More...
 
STL container types.
using value_type = typename Container_t::value_type
 
using reference = typename Container_t::reference
 
using const_reference = typename Container_t::const_reference
 
using pointer = typename Container_t::pointer
 
using const_pointer = typename Container_t::const_pointer
 
using iterator = details::GeoIDdataContainerIterator< Mapper_t, BaseIter_t >
 
using const_iterator = details::GeoIDdataContainerIterator< Mapper_t, BaseConstIter_t >
 
using difference_type = typename Container_t::difference_type
 
using size_type = typename Container_t::size_type
 
using item_iterator = details::GeoIDdataContainerItemIterator< iterator >
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 
using item_const_iterator = details::GeoIDdataContainerItemIterator< const_iterator >
 Special iterator dereferencing to pairs ( ID, value ) (see items()). More...
 

Public Member Functions

 GeoIDdataContainer ()=default
 Default constructor: container has no room at all. More...
 
 GeoIDdataContainer (std::initializer_list< unsigned int > dims)
 Prepares the container with default-constructed data. More...
 
 GeoIDdataContainer (std::initializer_list< unsigned int > dims, value_type const &defValue)
 Prepares the container initializing all its data. More...
 
Element access
reference operator[] (ID_t const &id)
 Returns the element for the specified geometry element. More...
 
const_reference operator[] (ID_t const &id) const
 Returns the element for the specified geometry element (read-only). More...
 
reference at (ID_t const &id)
 
const_reference at (ID_t const &id) const
 
reference first ()
 Returns the element for the first ID (unchecked). More...
 
const_reference first () const
 Returns the element for the first ID (unchecked). More...
 
reference last ()
 Returns the element for the last ID (unchecked). More...
 
const_reference last () const
 Returns the element for the last ID (unchecked). More...
 
Iterators

Two types of iterators are provided:

  1. "standard" iterators pointing to data values
  2. "item" pseudo-iterators dereferencing to a (ID, value) pair

Reverse iterators are not supported (yet?).

Standard iterators

The STL-like interface provides iterators that go through the entire range of allowed data, i.e. all the size() elements that are also reached via random access (operator[]()).

These iterators have an interface extension: the data member ID() returns the ID of the element the iterator is pointing to. For example:

auto iData = data.begin();
auto const dend = data.end();
while (iData != dend) {
std::cout << "data[" << iData.ID() << "] = " << *iData << std::endl;
++iData;
} // while

Note that using the range-for loop, you don't get access to the iterator and therefore not even to the ID.

Item iterators

The item iterators are iterators adapted from the standard ones, which when dereferenced return a pair ( ID_t, reference ). They can be accessed with item_begin(), item_end() etc, and range-for loop can be obtained via items() member function:

for (auto&& [ ID, value ]: data.items()) {
std::cout << "data[" << ID << "] = " << value << std::endl;
}

(this loop has the same effect as the one in the example of the standard iterators, but it's more compact).

iterator begin ()
 Returns an iterator to the beginning of the data. More...
 
iterator end ()
 Returns an iterator to past the end of the data. More...
 
const_iterator begin () const
 Returns a constant iterator to the beginning of the data. More...
 
const_iterator end () const
 Returns a constant iterator to past the end of the data. More...
 
const_iterator cbegin () const
 Returns a constant iterator to the beginning of the data. More...
 
const_iterator cend () const
 Returns a constant iterator to past the end of the data. More...
 
item_iterator item_begin ()
 Returns an item iterator to the beginning of the data. More...
 
item_iterator item_end ()
 Returns an item iterator to past the end of the data. More...
 
item_const_iterator item_begin () const
 Returns a item constant iterator to the beginning of the data. More...
 
item_const_iterator item_end () const
 Returns a item constant iterator to past the end of the data. More...
 
item_const_iterator item_cbegin () const
 Returns a item constant iterator to the beginning of the data. More...
 
item_const_iterator item_cend () const
 Returns a item constant iterator to past the end of the data. More...
 
auto items ()
 Returns an object suitable for a range-for loop with item_iterator. More...
 
auto items () const
 Returns an object suitable for a range-for loop with item_const_iterator. More...
 
Data modification

In general, each single element can be accessed and changed. In addition, this section includes methods acting on multiple elements at once.

void fill (value_type value)
 Sets all elements to the specified value (copied). More...
 
void reset ()
 Sets all the elements to a default-constructed value_type. More...
 
template<typename Op >
Op apply (Op &&op)
 Applies an operation on all elements. More...
 
template<typename Op >
decltype(auto) apply (Op &&op) const
 Applies an operation on all elements. More...
 
Container modification
void resize (std::initializer_list< unsigned int > dims)
 Prepares the container with default-constructed data. More...
 
void resize (std::initializer_list< unsigned int > dims, value_type const &defValue)
 Prepares the container initializing all its data. More...
 
template<typename OT >
void resizeAs (geo::GeoIDdataContainer< OT, Mapper_t > const &other)
 Prepares the container with default-constructed data. More...
 
template<typename OT >
void resizeAs (geo::GeoIDdataContainer< OT, Mapper_t > const &other, value_type const &defValue)
 Prepares the container initializing all its data. More...
 
void clear ()
 Makes the container empty, with no usable storage space. More...
 

Private Types

using This_t = geo::GeoIDdataContainer< T, Mapper >
 Type of this class. More...
 
using Container_t = details::GeoContainerData< T >
 Type of data container helper. More...
 
using BaseIter_t = typename Container_t::iterator
 Type of iterator to the data. More...
 
using BaseConstIter_t = typename Container_t::const_iterator
 Type of constant iterator to the data. More...
 

Private Member Functions

size_type index (ID_t const &id) const
 Returns the internal index of the specified ID in the storage area. More...
 
ID_t ID (size_type const index) const
 Returns the ID corresponding to a internal index in the storage area. More...
 

Private Attributes

Mapper_t fMapper
 Mapping of IDs to indices. More...
 
Container_t fData
 Data storage. More...
 

Container status query

size_type size () const
 Returns the number of elements in the container. More...
 
size_type capacity () const
 Returns the number of elements the container has memory for. More...
 
bool empty () const
 Returns whether the container has no elements (false by assumptions). More...
 
template<std::size_t Level>
unsigned int dimSize () const
 Dimensions of the Level dimension of this container. More...
 
template<typename GeoID >
bool hasElement (GeoID const &id) const
 Returns whether this container hosts data for the specified ID. More...
 
template<typename GeoID = ID_t>
GeoID firstID () const
 Returns the ID of the first element with GeoID type. More...
 
template<typename GeoID = ID_t>
GeoID lastID () const
 Returns the ID of the last covered element with GeoID type. More...
 
Mapper_t const & mapper () const
 Returns the mapper object used to convert ID's and container positions. More...
 
static constexpr unsigned int dimensions ()
 Dimensions of the ID of this container. More...
 

Detailed Description

template<typename T, typename Mapper>
class geo::GeoIDdataContainer< T, Mapper >

Container with one element per geometry TPC.


Template Parameters
Ttype of the contained datum
See Also
geo::GeometryCore::makeTPCData

The container is of fixed size and can't be neither resized nor freed before destruction.

This example creates a "map" of tracks starting on each TPC:

auto const* geom = lar::providerFrom<geo::GeometryCore>();
(geom->NCryostats(), geom->MaxTPCs());
for (recob::Track const& track: tracks) {
geo::TPCGeo const* tpc = geom->PositionToTPCptr(track.Start());
if (tpc) TracksPerTPC[tpc->ID()].push_back(tpc);
} // for

Assumptions

The following assumptions should be considered unchecked, and the behavior when they are violated undefined (but note that in debug mode some of them might be actually checked):

Definition at line 36 of file GeometryDataContainers.h.

Member Typedef Documentation

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::BaseConstIter_t = typename Container_t::const_iterator
private

Type of constant iterator to the data.

Definition at line 114 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::BaseIter_t = typename Container_t::iterator
private

Type of iterator to the data.

Definition at line 111 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::const_iterator = details::GeoIDdataContainerIterator<Mapper_t, BaseConstIter_t>

Definition at line 138 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::const_pointer = typename Container_t::const_pointer

Definition at line 136 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::const_reference = typename Container_t::const_reference

Definition at line 134 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::Container_t = details::GeoContainerData<T>
private

Type of data container helper.

Definition at line 108 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::difference_type = typename Container_t::difference_type

Definition at line 141 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::ID_t = typename Mapper_t::ID_t

Type used as ID for this container.

Definition at line 127 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::item_const_iterator = details::GeoIDdataContainerItemIterator<const_iterator>

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 148 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::item_iterator = details::GeoIDdataContainerItemIterator<iterator>

Special iterator dereferencing to pairs ( ID, value ) (see items()).

Definition at line 145 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::iterator = details::GeoIDdataContainerIterator<Mapper_t, BaseIter_t>

Definition at line 137 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::Mapper_t = Mapper

Type of mapper between IDs and index.

Definition at line 125 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::pointer = typename Container_t::pointer

Definition at line 135 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::reference = typename Container_t::reference

Definition at line 133 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::size_type = typename Container_t::size_type

Definition at line 142 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::This_t = geo::GeoIDdataContainer<T, Mapper>
private

Type of this class.

Definition at line 105 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
using geo::GeoIDdataContainer< T, Mapper >::value_type = typename Container_t::value_type

Definition at line 132 of file GeometryDataContainers.h.

Constructor & Destructor Documentation

template<typename T, typename Mapper>
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer ( )
default

Default constructor: container has no room at all.

See Also
resize()

The object must be resized before being of any use.

template<typename T , typename Mapper >
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer ( std::initializer_list< unsigned int >  dims)

Prepares the container with default-constructed data.

Parameters
dimsnumber of elements on all levels of the container
See Also
resize()

The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).

The container is sized to host data for all the elements. Each element in the container is default-constructed.

Definition at line 1226 of file GeometryDataContainers.h.

1227  : fMapper(dims)
1228  , fData(fMapper.size())
1229 {
1230  assert(!fData.empty());
1231 }
bool empty() const
Returns whether the container has no elements (false by assumptions).
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
geo::GeoIDdataContainer< T, Mapper >::GeoIDdataContainer ( std::initializer_list< unsigned int >  dims,
value_type const &  defValue 
)

Prepares the container initializing all its data.

Parameters
dimsnumber of elements on all levels of the container
defValuethe value copied to fill all entries in the container
See Also
resize()

The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).

The container is sized to host data for all the elements. Each element in the container is constructed as copy of defValue.

Definition at line 1237 of file GeometryDataContainers.h.

1238  : fMapper(dims)
1239  , fData(fMapper.computeSize(), defValue)
1240 {
1241  assert(!fData.empty());
1242 }
bool empty() const
Returns whether the container has no elements (false by assumptions).
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.

Member Function Documentation

template<typename T , typename Mapper >
template<typename Op >
Op geo::GeoIDdataContainer< T, Mapper >::apply ( Op &&  op)

Applies an operation on all elements.

Template Parameters
Optype of operation
Parameters
opOperation
Returns
the operation object after operations took place

The operation op is a unary functor, i.e. an object that supports the call to op(value_type&).

The return values of op calls are discarded.

Definition at line 1461 of file GeometryDataContainers.h.

1462  { return fData.apply(std::forward<Op>(op)); }
Op apply(Op &&op)
Applies an operation on all elements.
Container_t fData
Data storage.
template<typename T, typename Mapper>
template<typename Op >
decltype(auto) geo::GeoIDdataContainer< T, Mapper >::apply ( Op &&  op) const

Applies an operation on all elements.

Template Parameters
Optype of operation
Parameters
opOperation
Returns
the operation object after operations took place

The operation op is a unary functor, i.e. an object that supports the call to op(value_type const&).

The return values of op calls are discarded. Note that while the elements of this container can't be modified, the operation itself still can if not constant, and it is returned.

template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::at ( ID_t const &  id)

Returns the element for the specified geometry element.

Exceptions
std::out_of_rangeif element id is not within the container range

Definition at line 1318 of file GeometryDataContainers.h.

1318  {
1319  if (hasElement(id)) return operator[](id);
1320  throw std::out_of_range("No data for " + std::string(id));
1321 } // geo::GeoIDdataContainer<>::at()
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
bool hasElement(GeoID const &id) const
Returns whether this container hosts data for the specified ID.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::at ( ID_t const &  id) const

Returns the element for the specified geometry element (read-only).

Exceptions
std::out_of_rangeif element id is not within the container range

Definition at line 1326 of file GeometryDataContainers.h.

1328 {
1329  if (hasElement(id)) return operator[](id);
1330  throw std::out_of_range("No data for " + std::string(id));
1331 } // geo::GeoIDdataContainer<>::at() const
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
bool hasElement(GeoID const &id) const
Returns whether this container hosts data for the specified ID.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::begin ( )

Returns an iterator to the beginning of the data.

Definition at line 1360 of file GeometryDataContainers.h.

1361  { return { mapper(), fData.begin(), fData.begin() }; }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::begin ( ) const

Returns a constant iterator to the beginning of the data.

Definition at line 1372 of file GeometryDataContainers.h.

1373  { return { mapper(), fData.begin(), fData.begin() }; }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::capacity ( ) const

Returns the number of elements the container has memory for.

Definition at line 1253 of file GeometryDataContainers.h.

1254  { return fData.capacity(); }
size_type capacity() const
Returns the number of elements the container has memory for.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::cbegin ( ) const

Returns a constant iterator to the beginning of the data.

Definition at line 1384 of file GeometryDataContainers.h.

1385  { return begin(); }
iterator begin()
Returns an iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::cend ( ) const

Returns a constant iterator to past the end of the data.

Definition at line 1390 of file GeometryDataContainers.h.

1391  { return end(); }
iterator end()
Returns an iterator to past the end of the data.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::clear ( )

Makes the container empty, with no usable storage space.

See Also
resize()

The container needs to be resized before it is useful again.

Definition at line 1509 of file GeometryDataContainers.h.

1509  {
1510  fMapper.clear();
1511  fData.clear();
1512 } // geo::GeoIDdataContainer<>::clear()
void clear()
Makes the container empty, with no usable storage space.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
constexpr unsigned int geo::GeoIDdataContainer< T, Mapper >::dimensions ( )
static

Dimensions of the ID of this container.

Definition at line 1272 of file GeometryDataContainers.h.

template<typename T , typename Mapper >
template<std::size_t Level>
unsigned int geo::GeoIDdataContainer< T, Mapper >::dimSize ( ) const

Dimensions of the Level dimension of this container.

Definition at line 1266 of file GeometryDataContainers.h.

1267  { return mapper().template dimSize<Level>(); }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
bool geo::GeoIDdataContainer< T, Mapper >::empty ( ) const

Returns whether the container has no elements (false by assumptions).

Definition at line 1259 of file GeometryDataContainers.h.

1260  { return fData.empty(); }
bool empty() const
Returns whether the container has no elements (false by assumptions).
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::end ( )

Returns an iterator to past the end of the data.

Definition at line 1366 of file GeometryDataContainers.h.

1367  { return { mapper(), fData.begin(), fData.end() }; }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::end ( ) const

Returns a constant iterator to past the end of the data.

Definition at line 1378 of file GeometryDataContainers.h.

1379  { return { mapper(), fData.begin(), fData.end() }; }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::fill ( value_type  value)

Sets all elements to the specified value (copied).

Definition at line 1448 of file GeometryDataContainers.h.

1449  { fData.fill(value); }
temporary value
Container_t fData
Data storage.
void fill(value_type value)
Sets all elements to the specified value (copied).
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::first ( )

Returns the element for the first ID (unchecked).

Definition at line 1336 of file GeometryDataContainers.h.

1337  { return operator[](firstID()); }
GeoID firstID() const
Returns the ID of the first element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::first ( ) const

Returns the element for the first ID (unchecked).

Definition at line 1342 of file GeometryDataContainers.h.

1343  { return operator[](firstID()); }
GeoID firstID() const
Returns the ID of the first element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
template<typename GeoID >
GeoID geo::GeoIDdataContainer< T, Mapper >::firstID ( ) const

Returns the ID of the first element with GeoID type.

Definition at line 1286 of file GeometryDataContainers.h.

1287  { return mapper().template firstID<GeoID>(); }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
template<typename GeoID >
bool geo::GeoIDdataContainer< T, Mapper >::hasElement ( GeoID const &  id) const

Returns whether this container hosts data for the specified ID.

Definition at line 1279 of file GeometryDataContainers.h.

1280  { return mapper().template hasElement<GeoID>(id); }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::ID ( size_type const  index) const
private

Returns the ID corresponding to a internal index in the storage area.

Definition at line 1531 of file GeometryDataContainers.h.

1532  { return mapper().ID(index); }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
size_type index(ID_t const &id) const
Returns the internal index of the specified ID in the storage area.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::index ( ID_t const &  id) const
private

Returns the internal index of the specified ID in the storage area.

Definition at line 1524 of file GeometryDataContainers.h.

1526  { return mapper().index(id); }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_begin ( )

Returns an item iterator to the beginning of the data.

Definition at line 1396 of file GeometryDataContainers.h.

1397  { return { begin() }; }
iterator begin()
Returns an iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_begin ( ) const

Returns a item constant iterator to the beginning of the data.

Definition at line 1408 of file GeometryDataContainers.h.

1410  { return { begin() }; }
iterator begin()
Returns an iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_cbegin ( ) const

Returns a item constant iterator to the beginning of the data.

Definition at line 1422 of file GeometryDataContainers.h.

1424  { return item_begin(); }
item_iterator item_begin()
Returns an item iterator to the beginning of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_cend ( ) const

Returns a item constant iterator to past the end of the data.

Definition at line 1429 of file GeometryDataContainers.h.

1431  { return item_end(); }
item_iterator item_end()
Returns an item iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_end ( )

Returns an item iterator to past the end of the data.

Definition at line 1402 of file GeometryDataContainers.h.

1403  { return { end() }; }
iterator end()
Returns an iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::item_end ( ) const

Returns a item constant iterator to past the end of the data.

Definition at line 1415 of file GeometryDataContainers.h.

1417  { return { end() }; }
iterator end()
Returns an iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::items ( )

Returns an object suitable for a range-for loop with item_iterator.

Definition at line 1436 of file GeometryDataContainers.h.

1437  { return util::span{ item_begin(), item_end() }; }
Simple class with a begin and an end.
Definition: span.h:125
item_iterator item_begin()
Returns an item iterator to the beginning of the data.
item_iterator item_end()
Returns an item iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::items ( ) const

Returns an object suitable for a range-for loop with item_const_iterator.

Definition at line 1442 of file GeometryDataContainers.h.

1443  { return util::span{ item_begin(), item_end() }; }
Simple class with a begin and an end.
Definition: span.h:125
item_iterator item_begin()
Returns an item iterator to the beginning of the data.
item_iterator item_end()
Returns an item iterator to past the end of the data.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::last ( )

Returns the element for the last ID (unchecked).

Definition at line 1348 of file GeometryDataContainers.h.

1349  { return operator[](lastID()); }
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::last ( ) const

Returns the element for the last ID (unchecked).

Definition at line 1354 of file GeometryDataContainers.h.

1355  { return operator[](lastID()); }
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
template<typename T , typename Mapper >
template<typename GeoID >
GeoID geo::GeoIDdataContainer< T, Mapper >::lastID ( ) const

Returns the ID of the last covered element with GeoID type.

Definition at line 1293 of file GeometryDataContainers.h.

1294  { return mapper().template lastID<GeoID>(); }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::mapper ( ) const

Returns the mapper object used to convert ID's and container positions.

Definition at line 1299 of file GeometryDataContainers.h.

1300  { return fMapper; }
Mapper_t fMapper
Mapping of IDs to indices.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::operator[] ( ID_t const &  id)

Returns the element for the specified geometry element.

Definition at line 1305 of file GeometryDataContainers.h.

1306  { return fData[mapper().index(id)]; }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::operator[] ( ID_t const &  id) const

Returns the element for the specified geometry element (read-only).

Definition at line 1311 of file GeometryDataContainers.h.

1313  { return fData[mapper().index(id)]; }
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::reset ( )

Sets all the elements to a default-constructed value_type.

Definition at line 1454 of file GeometryDataContainers.h.

1455  { fData.reset(); }
void reset()
Sets all the elements to a default-constructed value_type.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::resize ( std::initializer_list< unsigned int >  dims)

Prepares the container with default-constructed data.

Parameters
dimsnumber of elements on all levels of the container
See Also
clear(), fill()

The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).

The container is sized to host data for all the elements. Each new element in the container is default-constructed. Existing data is not touched, but it may be rearranged in a non-straightforward way.

Definition at line 1468 of file GeometryDataContainers.h.

1469 {
1470  fMapper.resize(dims);
1471  fData.resize(mapper().size());
1472 } // geo::GeoIDdataContainer<T, Mapper>::resize()
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
void geo::GeoIDdataContainer< T, Mapper >::resize ( std::initializer_list< unsigned int >  dims,
value_type const &  defValue 
)

Prepares the container initializing all its data.

Parameters
dimsnumber of elements on all levels of the container
defValuethe value copied to fill all entries in the container
See Also
clear(), fill()

The size of each dimension is specified by the corresponding number, starting from the size of the outer dimension (cryostat).

The container is sized to host data for all the elements. Each new element in the container is constructed as copy of defValue. Existing data is not touched, but it may be rearranged in a non-straightforward way.

Definition at line 1478 of file GeometryDataContainers.h.

1479 {
1480  fMapper.resize(dims);
1481  fData.resize(mapper().size(), defValue);
1482 } // geo::GeoIDdataContainer<T, Mapper>::resize(value_type)
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
template<typename OT >
void geo::GeoIDdataContainer< T, Mapper >::resizeAs ( geo::GeoIDdataContainer< OT, Mapper_t > const &  other)

Prepares the container with default-constructed data.

Parameters
otherdata collection to take dimensions from

The size of each dimension is taken by the matching one in other.

The container is sized to host data for all the elements. Each new element in the container is default-constructed. Existing data is not touched, but it may be rearranged in a non-straightforward way.

Definition at line 1489 of file GeometryDataContainers.h.

1490 {
1491  fMapper.resizeAs(other.mapper());
1492  fData.resize(mapper().size());
1493 } // geo::GeoIDdataContainer<T, Mapper>::resizeAs()
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
template<typename OT >
void geo::GeoIDdataContainer< T, Mapper >::resizeAs ( geo::GeoIDdataContainer< OT, Mapper_t > const &  other,
value_type const &  defValue 
)

Prepares the container initializing all its data.

Parameters
otherdata collection to take dimensions from
defValuethe value copied to fill all entries in the container

The size of each dimension is taken by the matching one in other.

The container is sized to host data for all the elements. Each new element in the container is constructed as copy of defValue. Existing data is not touched, but it may be rearranged in a non-straightforward way.

Definition at line 1500 of file GeometryDataContainers.h.

1501 {
1502  fMapper.resizeAs(other.mapper());
1503  fData.resize(mapper().size(), defValue);
1504 } // geo::GeoIDdataContainer<T, Mapper>::resizeAs(value_type)
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage.
template<typename T , typename Mapper >
auto geo::GeoIDdataContainer< T, Mapper >::size ( ) const

Returns the number of elements in the container.

Definition at line 1247 of file GeometryDataContainers.h.

1248  { return fData.size(); }
size_type size() const
Returns the number of elements in the container.
Container_t fData
Data storage.

Member Data Documentation

template<typename T, typename Mapper>
Container_t geo::GeoIDdataContainer< T, Mapper >::fData
private

Data storage.

Definition at line 500 of file GeometryDataContainers.h.

template<typename T, typename Mapper>
Mapper_t geo::GeoIDdataContainer< T, Mapper >::fMapper
private

Mapping of IDs to indices.

Definition at line 498 of file GeometryDataContainers.h.


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