artdaq::QuickVec Struct Reference

A QuickVec behaves like a std::vector, but does no initialization of its data, making it faster at the cost of having to ensure that uninitialized data is not read. More...

#include <artdaq-core/Core/QuickVec.hh>

List of all members.

Public Types

typedef TT_ * iterator
 Iterator is pointer-to-member type.
typedef const TT_ * const_iterator
 const_iterator is const-pointer-to-member type
typedef TT_ & reference
 reference is reference-to-member tpye
typedef const TT_ & const_reference
 const_reference is const-reference-to-member type
typedef TT_ value_type
 value_type is member type
typedef ptrdiff_t difference_type
 difference_type is ptrdiff_t
typedef size_t size_type
 size_type is size_t

Public Member Functions

 QuickVec (size_t sz)
 Allocates a QuickVec object, doing no initialization of allocated memory.
 QuickVec (size_t sz, TT_ val)
 Allocates a QuickVec object, initializing each element to the given value.
virtual ~QuickVec () noexcept
 Destructor calls free on data.
 QuickVec (std::vector< TT_ > &other)
 Copies the contents of a std::vector into a new QuickVec object.
void clear ()
 Sets the size to 0. QuickVec does not reinitialize memory, so no further action will be taken.
 QuickVec (const QuickVec &other)
 Copy Constructor.
QUICKVEC & operator= (const QuickVec &other)
 Copy assignment operator.
 QuickVec (QuickVec &&other) noexcept
 Move Constructor.
QUICKVEC & operator= (QuickVec &&other) noexcept
 Move assignemnt operator.
TT_ & operator[] (int idx)
 Returns a reference to a given element.
const TT_ & operator[] (int idx) const
 Returns a const reference to a given element.
size_t size () const
 Accesses the current size of the QuickVec.
size_t capacity () const
 Accesses the current capacity of the QuickVec.
iterator begin ()
 Gets an iterator to the beginning of the QuickVec.
const_iterator begin () const
 Gets a const_iterator to the beginning of the QuickVec.
iterator end ()
 Gets an iterator to the end of the QuickVec.
const_iterator end () const
 Gets a const_iterator to the end of the QuickVec.
void reserve (size_t size)
 Allocates memory for the QuickVec so that its capacity is at least size.
void resize (size_t size)
 Resizes the QuickVec.
void resizeWithCushion (size_t size, double growthFactor=1.3)
 Resizes the QuickVec and requests additional capacity.
void resize (size_t size, TT_ val)
 Resizes the QuickVec, initializes new elements with val.
iterator insert (const_iterator position, size_t nn, const TT_ &val)
 Inserts an element into the QuickVec.
iterator insert (const_iterator position, const_iterator first, const_iterator last)
 Inserts a range of elements into the QuickVec.
iterator erase (const_iterator first, const_iterator last)
 Erases elements in given range from the QuickVec.
void swap (QuickVec &other) noexcept
 Exchanges references to two QuickVec objects.
void push_back (const value_type &val)
 Adds a value to the QuickVec, resizing if necessary (adds 10% capacity).

Detailed Description

A QuickVec behaves like a std::vector, but does no initialization of its data, making it faster at the cost of having to ensure that uninitialized data is not read.

Template Parameters:
TT_ The data type stored in the QuickVec

Definition at line 86 of file QuickVec.hh.


Constructor & Destructor Documentation

artdaq::QuickVec::QuickVec ( size_t  sz  ) 

Allocates a QuickVec object, doing no initialization of allocated memory.

Parameters:
sz Size of QuickVec object to allocate
artdaq::QuickVec::QuickVec ( size_t  sz,
TT_  val 
)

Allocates a QuickVec object, initializing each element to the given value.

Parameters:
sz Size of QuickVec object to allocate
val Value with which to initialize elements
artdaq::QuickVec::QuickVec ( std::vector< TT_ > &  other  )  [inline]

Copies the contents of a std::vector into a new QuickVec object.

Parameters:
other The vector to copy

Definition at line 118 of file QuickVec.hh.

artdaq::QuickVec::QuickVec ( const QuickVec other  )  [inline]

Copy Constructor.

Parameters:
other QuickVec to copy

Definition at line 138 of file QuickVec.hh.

artdaq::QuickVec::QuickVec ( QuickVec &&  other  )  [inline]

Move Constructor.

Parameters:
other QuickVec to move from

Definition at line 166 of file QuickVec.hh.


Member Function Documentation

const_iterator artdaq::QuickVec::begin (  )  const

Gets a const_iterator to the beginning of the QuickVec.

Returns:
A const_iterator to the beginning of the QuickVec
iterator artdaq::QuickVec::begin (  ) 

Gets an iterator to the beginning of the QuickVec.

Returns:
An iterator to the beginning of the QuickVec
size_t artdaq::QuickVec::capacity (  )  const

Accesses the current capacity of the QuickVec.

Returns:
The current capacity of the QuickVec

Accesses the current capcity of the QuickVec. Like a vector, the capacity of a QuickVec object is defined as the maximum size it can hold before it must reallocate more memory.

const_iterator artdaq::QuickVec::end (  )  const

Gets a const_iterator to the end of the QuickVec.

Returns:
A const_iterator to the end of the QuickVec
iterator artdaq::QuickVec::end (  ) 

Gets an iterator to the end of the QuickVec.

Returns:
An iterator to the end of the QuickVec
iterator artdaq::QuickVec::erase ( const_iterator  first,
const_iterator  last 
)

Erases elements in given range from the QuickVec.

Parameters:
first First element to erase
last Last element to erase
Returns:
iterator to first element after erase range

Erases elements in given range from the QuickVec. Note that since the underlying data structure resembles a std::vector, erase operations are very inefficient! (O(n))

iterator artdaq::QuickVec::insert ( const_iterator  position,
const_iterator  first,
const_iterator  last 
)

Inserts a range of elements into the QuickVec.

Parameters:
position Position at which to insert
first const_iterator to first element to insert
last const_iterator to last element to insert
Returns:
Iterator to first inserted element

Inserts elements into the QuickVec. Note that since the underlying data structure resembles a std::vector, insert operations are very inefficient!

iterator artdaq::QuickVec::insert ( const_iterator  position,
size_t  nn,
const TT_ &  val 
)

Inserts an element into the QuickVec.

Parameters:
position Position at which to isnert
nn Number of copies of val to insert
val Value to insert
Returns:
Iterator to first inserted element

Inserts an element (or copies thereof) into the QuickVec. Note that since the underlying data structure resembles a std::vector, insert operations are very inefficient!

QUICKVEC& artdaq::QuickVec::operator= ( QuickVec &&  other  )  [inline]

Move assignemnt operator.

Parameters:
other QuickVec to move from
Returns:
Reference to new QuickVec object

Definition at line 181 of file QuickVec.hh.

QUICKVEC& artdaq::QuickVec::operator= ( const QuickVec other  )  [inline]

Copy assignment operator.

Parameters:
other QuickVec to copy
Returns:
Reference to new QuickVec object

Definition at line 153 of file QuickVec.hh.

const TT_& artdaq::QuickVec::operator[] ( int  idx  )  const

Returns a const reference to a given element.

Parameters:
idx Element to return
Returns:
const reference to element
TT_& artdaq::QuickVec::operator[] ( int  idx  ) 

Returns a reference to a given element.

Parameters:
idx Element to return
Returns:
Reference to element
void artdaq::QuickVec::push_back ( const value_type val  ) 

Adds a value to the QuickVec, resizing if necessary (adds 10% capacity).

Parameters:
val Value to add to the QuickVec
void artdaq::QuickVec::reserve ( size_t  size  ) 

Allocates memory for the QuickVec so that its capacity is at least size.

Parameters:
size The new capacity of the QuickVec

Allocates memory for the QuickVec so that its capacity is at least size. If the QuickVec is already at or above size in capacity, no allocation is performed.

void artdaq::QuickVec::resize ( size_t  size,
TT_  val 
)

Resizes the QuickVec, initializes new elements with val.

Parameters:
size New size of the QuickVec
val Value with which to initialize elements
void artdaq::QuickVec::resize ( size_t  size  ) 

Resizes the QuickVec.

Parameters:
size New size of the QuickVec

If size is smaller than the current size of the QuickVec, then it will change its size_ parameter (no reallocation, capacity does not change). If size is greater than the capacity of the QuickVec, a reallocation will occur.

void artdaq::QuickVec::resizeWithCushion ( size_t  size,
double  growthFactor = 1.3 
)

Resizes the QuickVec and requests additional capacity.

Parameters:
size New size of the QuickVec
growthFactor Factor to use when allocating additional capacity

This method updates the size of the QuickVec. If the new size is within the current capacity, no realloction takes place. If not, then the reallocation reserves additional capacity as a cushion against future needs to reallocate, based on the specified growth factor.

size_t artdaq::QuickVec::size (  )  const

Accesses the current size of the QuickVec.

Returns:
The current size of the QuickVec
void artdaq::QuickVec::swap ( QuickVec other  ) 

Exchanges references to two QuickVec objects.

Parameters:
other Other QuickVec to swap with

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

Generated on 5 Feb 2019 for artdaq_core by  doxygen 1.6.1