1 # ifndef CPPAD_UTILITY_VECTOR_HPP
2 # define CPPAD_UTILITY_VECTOR_HPP
337 template <
class Type>
373 for(
size_t i = 0; i <
length_; i++)
395 inline const Type*
data(
void)
const
438 "vector: size miss match in assignment operation"
444 # if CPPAD_USE_CPLUSPLUS_2011
452 "vector: size miss match in assignment operation"
463 x.data_ = CPPAD_NULL;
475 "vector: index greater than or equal vector size"
486 "vector: index greater than or equal vector size"
505 Type* old_data =
data_;
513 for(
size_t i = 0; i < old_length; i++)
514 data_[i] = old_data[i];
518 data_[old_length] = s;
521 if( old_capacity > 0 )
532 template <
class Vector>
537 { CheckSimpleVector<Type, Vector>();
542 {
for(
size_t i = 0; i < m; i++)
550 Type* old_data =
data_;
558 for(
size_t i = 0; i < old_length; i++)
559 data_[i] = old_data[i];
563 for(
size_t i = 0; i < m; i++)
564 data_[old_length + i] = v[i];
567 if( old_capacity > 0 )
576 template <
class Type>
583 size_t n = vec.
size();
624 operator bool()
const
651 = std::numeric_limits<UnitType>::digits;
686 data_ = thread_alloc::create_array<UnitType>(min_unit,
n_unit_);
697 data_ = thread_alloc::create_array<UnitType>(min_unit,
n_unit_);
702 for(i = 0; i < min_unit; i++)
734 data_ = thread_alloc::create_array<UnitType>(min_unit,
n_unit_);
758 "vectorBool: size miss match in assignment operation"
763 for(i = 0; i < min_unit; i++)
767 # if CPPAD_USE_CPLUSPLUS_2011
775 "vectorBool: size miss match in assignment operation"
786 x.data_ = CPPAD_NULL;
801 "vectorBool: index greater than or equal vector size"
813 "vectorBool: index greater than or equal vector size"
819 return (unit & mask) != 0;
837 for(i = 0; i < old_n_unit; i++)
838 data_[i] = old_data[i];
848 else data_[i] &= ~mask;
852 template <
class Vector>
857 { CheckSimpleVector<bool, Vector>();
874 data_ = thread_alloc::create_array<UnitType>(min_unit,
n_unit_);
876 for(i = 0; i < old_n_unit; i++)
877 data_[i] = old_data[i];
883 for(k = 0; k < v.size(); k++)
891 else data_[i] &= ~mask;
Type * data_
pointer to the first type elements (not defined and should not be used when capacity_ = 0) ...
size_t length_
number of bits currently stored in this vector
vector(size_t n)
sizing constructor
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
void push_back(bool bit)
add an element to the back of this vector
Class that is used to hold a non-constant element of a vector.
vectorBool(size_t n)
sizing constructor
size_t capacity_
maximum number of Type elements current allocation can hold
The CppAD Simple Vector template class.
size_t unit_min(void)
minimum number of UnitType values that can store length_ bits (note that this is really a function of...
static size_t bit_per_unit(void)
vector(void)
default constructor sets capacity_ = length_ = data_ = 0
std::ostream & operator<<(std::ostream &os, const CppAD::vector< Type > &vec)
output a vector
UnitType mask_
mask for the bit corresponding to this element (all zero except for bit that corresponds to this elem...
size_t n_unit_
number of UnitType values in data_
void clear(void)
free memory and set number of elements to zero
vectorBoolElement & operator=(bool bit)
assignment of this element to a bool
vector(const vector &x)
copy constructor
Type * data(void)
raw pointer to the data
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
Type & operator[](size_t i)
non-constant element access; i.e., we can change this element value
const Type * data(void) const
const raw pointer to the data
void resize(size_t n)
change the number of elements in this vector.
void clear(void)
free memory and set number of elements to zero
vector & operator=(vector &&x)
vector assignment operator with move semantics
~vectorBool(void)
destructor
vector & operator=(const vector &x)
vector assignment operator
bool value_type
type corresponding to the elements of this vector (note that non-const elements actually use vectorBo...
size_t capacity(void) const
maximum number of elements current allocation can store
size_t length_
number of Type elements currently in this vector
vectorBool & operator=(vectorBool &&x)
vector assignment operator with move semantics
size_t size(void) const
number of elements currently in this vector.
vectorBool & operator=(const vectorBool &v)
vector assignment operator
static void delete_array(Type *array)
Return Memory Used for an Array to the Available Pool (include destructor call for each element)...
vectorBoolElement(const vectorBoolElement &e)
constuctor from another element
void push_back(const Type &s)
add an element to the back of this vector
size_t capacity(void) const
maximum number of elements current allocation can store
bool operator[](size_t k) const
constant element access; i.e., we cannot change this element value
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
void delete_data(Type *data_ptr)
delete data pointer
UnitType * unit_
pointer to the UnitType value holding this eleemnt
static const size_t bit_per_unit_
number of bits packed into each UnitType value in data_
vectorBoolElement(UnitType *unit, UnitType mask)
constructor from member values
Type value_type
type of the elements in the vector
void push_vector(const Vector &v)
add vector to the back of this vector
UnitType * data_
pointer to where the bits are stored
size_t UnitType
the boolean data is packed with sizeof(UnitType) bits per value
File used to define the CppAD multi-threading allocator class.
void resize(size_t n)
change number of elements in this vector
vectorBoolElement & operator=(const vectorBoolElement &e)
assignment of this element to another element
size_t UnitType
the boolean data is packed with sizeof(UnitType) bits per value
vectorBoolElement operator[](size_t k)
non-constant element access; i.e., we can change this element value
vectorBool(const vectorBool &v)
copy constructor
vectorBool(void)
default constructor (sets all member data to zero)
const Type & operator[](size_t i) const
constant element access; i.e., we cannot change this element value
size_t size(void) const
number of elements in this vector
void push_vector(const Vector &v)
add vector to the back of this vector (we could not use push_back because MS V++ 7...