11 #ifndef LARDATAOBJ_UTILITIES_LAZYVECTOR_H 12 #define LARDATAOBJ_UTILITIES_LAZYVECTOR_H 18 #include <type_traits> 77 template <typename T, typename A = typename std::vector<T>::allocator_type>
482 template <
typename T,
typename A >
488 template <
typename T,
typename A >
495 template <
typename T,
typename A >
502 template <
typename T,
typename A >
510 template <
typename T,
typename A >
527 template <
typename T,
typename A >
543 template <
typename T,
typename A >
563 template <
typename T,
typename A >
582 template <
typename T,
typename A >
601 template <
typename T,
typename A >
621 template <
typename T,
typename A >
629 template <
typename T,
typename A >
635 if (startIndex >= e)
return;
638 storage().reserve(e - startIndex);
645 template <
typename T,
typename A >
651 if (startIndex >= e)
return;
661 template <
typename T,
typename A >
671 template <
typename T,
typename A >
681 template <
typename T,
typename A >
691 template <
typename T,
typename A >
700 template <
typename T,
typename A >
708 template <
typename T,
typename A >
716 template <
typename T,
typename A >
719 throw std::out_of_range(
720 "Index " +
std::to_string(pos) +
" is out of LazyVector range (size: " 728 #endif // LARDATAOBJ_UTILITIES_LAZYVECTOR_H const_pointer data_address(size_type pos) const
Returns a constant pointer to the specified element.
value_type operator[](size_type pos) const
Returns a copy of the specified element.
Namespace for general, non-LArSoft-specific utilities.
bool has_index(size_type pos) const noexcept
Returns whether the specified position is within the vector.
static value_type const & defaultValueType()
Returns the class default value (used when user does not specify any).
std::vector< TF1, typename std::vector< TF1 >::allocator_type > Data_t
Actual data storage type.
void data_prepare(size_type startIndex, size_type endIndex)
Prepares the vector to store elements in the specified range.
value_type const_get(size_type pos) const
Returns a copy of the specified element.
void data_clear()
Erases all stored data from the container; nominal size is not changed.
typename Data_t::reference reference
void data_init(size_type startIndex, size_type endIndex)
Allocates the specified range and stores default values for it.
void clear()
Removes all stored data and sets the nominal size to 0.
void check_range(size_type pos) const
Throws std::out_of_range if pos is not contained in the vector.
size_type index_of(size_type pos) const
Returns the internal storage index for the specified position.
void reserve(size_type n)
Allocates enough memory in storage to store n elements.
void expand_front(size_type pos)
Expands the storage to include the specified position behind it.
void shrink_to_fit()
Reduces memory usage to the amount needed by the elements with storage.
value_type const & data_defvalue() const
void fix_size()
Makes sure the nominal size is large enough to include all stored data.
static value_type const fDefaultDefaultValue
Default-initialised value of type value_type used as default fallback.
size_type size() const noexcept
Returns the size of the vector.
bool data_empty() const noexcept
Returns whether no data is actually stored.
bool empty() const noexcept
Returns whether the vector is empty.
typename Data_t::size_type size_type
Data_t fData
Actual data storage.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
size_type data_begin_index() const
Data_t & storage()
Returns the data storage.
typename Data_t::allocator_type allocator_type
void expand_back(size_type pos)
Expands the storage to include the specified position ahead of it.
typename Data_t::const_pointer const_pointer
void data_prepare(size_type n)
Prepares the vector to store n elements from 0.
value_type at(size_type pos) const
Returns a reference to the specified element, throws an exception if not present. ...
Data_t const & storage() const
Returns the data storage.
typename Data_t::difference_type difference_type
size_type fNominalSize
Alleged data size.
void data_init(size_type n)
Allocates and initializes n elements starting from index 0.
value_type const_at(size_type pos) const
Returns a reference to the specified element, throws an exception if not present. ...
void init(size_type pos, size_type n=1U)
Makes the first data allocation.
size_type fFirstIndex
First element currently stored.
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
size_type data_end_index() const
typename Data_t::value_type value_type
typename Data_t::pointer pointer
void expand(size_type pos)
Expands the storage to include the specified position.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
A contiguous data container expanded on write.
void resize(size_type newSize)
Changes the nominal size of the container.
bool data_has_index(size_type pos) const
Returns the internal storage index for the specified position.
typename Data_t::const_reference const_reference
size_type data_size() const noexcept
Returns the size of data actually stored.
value_type fDefValue
Default value.