35 #ifndef _BLAZE_UTIL_PTRVECTOR_H_
36 #define _BLAZE_UTIL_PTRVECTOR_H_
280 ,
typename D = PtrDelete
281 ,
typename G = OptimalGrowth >
287 template<
typename T2,
typename D2,
typename G2 >
friend class PtrVector;
325 template<
typename T2,
typename D2,
typename G2 >
342 template<
typename T2,
typename D2,
typename G2 >
392 template<
typename IteratorType >
397 template<
typename IteratorType >
401 template<
typename IteratorType >
409 inline void clear ();
425 inline size_t calcCapacity (
size_t minCapacity )
const;
436 template<
typename IteratorType >
439 template<
typename IteratorType >
443 template<
typename IteratorType >
473 template<
typename L,
typename R >
474 friend inline bool operator==(
const CastIterator<L>& lhs,
const CastIterator<R>& rhs )
476 return lhs.base() == rhs.base();
487 template<
typename L,
typename R >
488 friend inline bool operator==(
const CastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
490 return lhs.base() == rhs.base();
501 template<
typename L,
typename R >
502 friend inline bool operator==(
const ConstCastIterator<L>& lhs,
const CastIterator<R>& rhs )
504 return lhs.base() == rhs.base();
515 template<
typename L,
typename R >
516 friend inline bool operator==(
const ConstCastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
518 return lhs.base() == rhs.base();
529 template<
typename L,
typename R >
530 friend inline bool operator!=(
const CastIterator<L>& lhs,
const CastIterator<R>& rhs )
532 return lhs.base() != rhs.base();
543 template<
typename L,
typename R >
544 friend inline bool operator!=(
const CastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
546 return lhs.base() != rhs.base();
557 template<
typename L,
typename R >
558 friend inline bool operator!=(
const ConstCastIterator<L>& lhs,
const CastIterator<R>& rhs )
560 return lhs.base() != rhs.base();
571 template<
typename L,
typename R >
572 friend inline bool operator!=(
const ConstCastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
574 return lhs.base() != rhs.base();
639 template<
typename T2
674 deleteElement( *it );
699 if( &pv ==
this )
return *
this;
729 template<
typename T2
822 template<
typename C >
926 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the front element" );
944 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the front element" );
962 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the back element" );
980 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the back element" );
1014 template<
typename T
1069 template<
typename T
1072 template<
typename C >
1125 template<
typename T
1128 template<
typename C >
1141 template<
typename T
1156 template<
typename T
1208 template<
typename T
1211 template<
typename C >
1214 return CastIterator<C>(
end_,
end_ );
1261 template<
typename T
1264 template<
typename C >
1267 return ConstCastIterator<C>(
end_,
end_ );
1289 template<
typename T
1316 template<
typename T
1321 deleteElement( *--
end_ );
1337 template<
typename T
1360 template<
typename T
1363 template<
typename IteratorType >
1367 insert( end(), first, last );
1383 template<
typename T
1388 T**
const base =
const_cast<T**
>( pos.
base() );
1418 template<
typename T
1421 template<
typename IteratorType >
1424 insert( pos, first, last,
typename IteratorType::iterator_category() );
1443 template<
typename T
1446 template<
typename IteratorType >
1449 insert( pos, first, last, std::random_access_iterator_tag() );
1466 template<
typename T
1471 T**
const base =
const_cast<T**
>( pos.
base() );
1472 deleteElement( *base );
1473 std::copy( base+1,
end_, base );
1494 template<
typename T
1497 template<
typename C >
1501 T**
const base =
const_cast<T**
>( pos.
base() );
1502 deleteElement( *base );
1503 std::copy( base+1,
end_, base );
1523 template<
typename T
1528 T**
const base =
const_cast<T**
>( pos.
base() );
1529 std::copy( base+1,
end_, base );
1549 template<
typename T
1552 template<
typename C >
1556 T**
const base =
const_cast<T**
>( pos.
base() );
1557 std::copy( base+1,
end_, base );
1572 template<
typename T
1578 deleteElement( *it );
1600 template<
typename T
1608 newCapacity = calcCapacity( newCapacity );
1631 template<
typename T
1660 template<
typename T
1679 template<
typename T
1705 template<
typename T
1711 std::copy_backward( pos,
end_,
end_+1 );
1716 else if( size_ == maxSize() ) {
1717 throw std::length_error(
"Maximum pointer vector length exceeded!" );
1721 if( newCapacity > maxSize() || newCapacity <
capacity_ ) newCapacity = maxSize();
1727 end_ = std::copy( pos,
end_, newEnd );
1751 template<
typename T
1754 template<
typename IteratorType >
1756 std::input_iterator_tag )
1758 for( ; first!=last; ++first ) {
1759 pos = insert( pos, *first );
1780 template<
typename T
1783 template<
typename IteratorType >
1785 std::random_access_iterator_tag )
1787 T**
const base =
const_cast<T**
>( pos.base() );
1788 const SizeType diff( last - first );
1791 for( ; first!=last; ++first, ++
end_ ) {
1797 insert( base, first, last, diff );
1814 template<
typename T
1817 template<
typename IteratorType >
1820 const SizeType newSize( size_ + n );
1823 std::copy_backward( pos,
end_,
end_+n );
1824 for( ; first!=last; ++first, ++pos ) {
1830 else if( newSize > maxSize() || newSize < size_ ) {
1831 throw std::length_error(
"Maximum pointer vector length exceeded!" );
1837 for( ; first!=last; ++first, ++newEnd ) {
1841 end_ = std::copy( pos,
end_, newEnd );
1863 template<
typename T,
typename D,
typename G >
1866 template<
typename T,
typename D,
typename G >
1869 template<
typename T,
typename D,
typename G >
1882 template<
typename T
1899 template<
typename T
1917 template<
typename T
1962 template<
typename T
1965 template<
typename C >
1966 class PtrVector<T,D,G>::CastIterator
1992 template<
typename Other >
2054 template<
typename T
2057 template<
typename C >
2073 template<
typename T
2076 template<
typename C >
2098 template<
typename T
2101 template<
typename C >
2102 template<
typename Other >
2126 template<
typename T
2129 template<
typename C >
2140 cur_ = polymorphicFind<C>( ++cur_,
end_ );
2152 template<
typename T
2155 template<
typename C >
2168 cur_ = polymorphicFind<C>( ++cur_,
end_ );
2188 template<
typename T
2191 template<
typename C >
2195 return static_cast<C*
>( *cur_ );
2205 template<
typename T
2208 template<
typename C >
2212 return static_cast<C*
>( *cur_ );
2230 template<
typename T
2233 template<
typename C >
2247 template<
typename T
2250 template<
typename C >
2295 template<
typename T
2298 template<
typename C >
2325 template<
typename Other >
2328 template<
typename Other >
2390 template<
typename T
2393 template<
typename C >
2409 template<
typename T
2412 template<
typename C >
2434 template<
typename T
2437 template<
typename C >
2438 template<
typename Other >
2454 template<
typename T
2457 template<
typename C >
2458 template<
typename Other >
2482 template<
typename T
2485 template<
typename C >
2496 cur_ = polymorphicFind<const C>( ++cur_,
end_ );
2508 template<
typename T
2511 template<
typename C >
2524 cur_ = polymorphicFind<const C>( ++cur_,
end_ );
2544 template<
typename T
2547 template<
typename C >
2551 return static_cast<const C*
>( *cur_ );
2561 template<
typename T
2564 template<
typename C >
2568 return static_cast<const C*
>( *cur_ );
2586 template<
typename T
2589 template<
typename C >
2603 template<
typename T
2606 template<
typename C >
Pointer difference type of the Blaze library.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
DifferenceType difference_type
Difference between two iterators.
Definition: PtrVector.h:2316
void assign(IteratorType first, IteratorType last)
Assigning a range of elements to the pointer vector.
Definition: PtrVector.h:1364
friend bool operator==(const CastIterator< L > &lhs, const CastIterator< R > &rhs)
Equality comparison between two CastIterator objects.
Definition: PtrVector.h:474
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:3703
ReferenceType reference
Reference return type.
Definition: PtrVector.h:1982
IteratorType cur_
Pointer to the current memory location.
Definition: PtrVector.h:2371
ReferenceType reference
Reference to a non-const object.
Definition: PtrVector.h:309
friend bool operator!=(const ConstCastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Inequality comparison between two ConstCastIterator objects.
Definition: PtrVector.h:572
ConstReferenceType const_reference
Reference to a const object.
Definition: PtrVector.h:310
IteratorType end_
Pointer to the element one past the last element in the element range.
Definition: PtrVector.h:2036
Iterator insert(Iterator pos, PointerType p)
Inserting an element into the pointer vector.
Definition: PtrVector.h:1386
ReferenceType operator[](SizeType index)
Subscript operator for the direct access to the pointer vector elements.
Definition: PtrVector.h:889
Iterator begin()
Returns an iterator to the beginning of the pointer vector.
Definition: PtrVector.h:1002
void pushBack(PointerType p)
Adding an element to the end of the pointer vector.
Definition: PtrVector.h:1292
#define BLAZE_CONSTRAINT_MUST_BE_CONVERTIBLE(FROM, TO)
Constraint on the pointer relationship.In case FROM is not convertible to TO, a compilation error is ...
Definition: Convertible.h:78
const blaze::Null NULL
Global NULL pointer.This instance of the Null class replaces the NULL macro to ensure a type-safe NUL...
Definition: Null.h:300
void releaseBack()
Releasing the element at the end of the pointer vector.
Definition: PtrVector.h:1340
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: PtrVector.h:1975
Header file for a safe C++ NULL pointer implementation.
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: PtrVector.h:1971
Iterator class for pointer vectors.
Iterator end()
Returns an iterator just past the last element of the pointer vector.
Definition: PtrVector.h:1144
#define BLAZE_CONSTRAINT_MUST_BE_STRICTLY_DERIVED_FROM(D, B)
Constraint on the inheritance relationship of a data type.In case D is not derived from B...
Definition: DerivedFrom.h:157
size_t SizeType
Size type of the pointer vector.
Definition: PtrVector.h:299
T *const * IteratorType
Type of the internal pointer.
Definition: PtrVector.h:1976
G GrowthPolicy
Type of the growth policy.
Definition: PtrVector.h:303
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
SizeType size_type
Size type of the pointer vector.
Definition: PtrVector.h:311
void clear()
Removing all elements from the pointer vector.
Definition: PtrVector.h:1575
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2513
friend bool operator!=(const CastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Inequality comparison between a CastIterator and a ConstCastIterator.
Definition: PtrVector.h:544
~PtrVector()
Destructor for PtrVector.
Definition: PtrVector.h:671
C *const & ReferenceType
Reference return type.
Definition: PtrVector.h:1974
SizeType capacity() const
Returns the capacity of the pointer vector.
Definition: PtrVector.h:848
Header file for the PtrDelete policy classes.
IteratorCategory iterator_category
The iterator category.
Definition: PtrVector.h:1979
IteratorType cur_
Pointer to the current memory location.
Definition: PtrVector.h:2035
Header file for nested template disabiguation.
Dynamic cast iterator for polymorphic pointer vectors.The ConstCastIterator class is part of the PtrV...
Definition: PtrVector.h:316
ReferenceType back()
Returns a reference to the last element of the pointer vector.
Definition: PtrVector.h:960
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4541
T * PointerType
Pointer to a non-const object.
Definition: PtrVector.h:295
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
PointerType pointer
Pointer return type.
Definition: PtrVector.h:1981
Constraint on the pointer relationship.
PtrVector(SizeType initCapacity=0)
Standard constructor for PtrVector.
Definition: PtrVector.h:602
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:2515
ValueType value_type
Type of the underlying pointers.
Definition: PtrVector.h:2313
ValueType value_type
Type of the underlying values.
Definition: PtrVector.h:306
friend bool operator==(const CastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Equality comparison between a CastIterator and a ConstCastIterator.
Definition: PtrVector.h:488
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: PtrVector.h:2304
C * PointerType
Pointer return type.
Definition: PtrVector.h:1973
friend bool operator==(const ConstCastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Equality comparison between two ConstCastIterator objects.
Definition: PtrVector.h:516
Constraint on the inheritance relationship of a data type.
const C *const & ReferenceType
Reference return type.
Definition: PtrVector.h:2307
Iterator release(Iterator pos)
Releasing an element from the pointer vector.
Definition: PtrVector.h:1526
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: PtrVector.h:2308
ReferenceType reference
Reference return type.
Definition: PtrVector.h:2315
PointerType pointer
Pointer return type.
Definition: PtrVector.h:2314
const C * PointerType
Pointer return type.
Definition: PtrVector.h:2306
bool isEmpty() const
Returns true if the pointer vector has no elements.
Definition: PtrVector.h:863
Headerfile for generic algorithms.
Implementation of a single thread of execution.
Definition: Thread.h:200
Implementation of an iterator for pointer vectors.The PtrIterator class follows the example of the ra...
Definition: PtrIterator.h:108
PointerType pointer
Pointer to a non-const object.
Definition: PtrVector.h:307
Dynamic cast iterator for polymorphic pointer vectors.The CastIterator class is part of the PtrVector...
Definition: PtrVector.h:315
void reserve(SizeType newCapacity)
Setting the minimum capacity of the pointer vector.
Definition: PtrVector.h:1603
SizeType capacity_
The capacity of the pointer vector.
Definition: PtrVector.h:452
SizeType size() const
Returns the current size of the pointer vector.
Definition: PtrVector.h:784
Header file for run time assertion macros.
PtrIterator< const T > ConstIterator
Iterator over const objects.
Definition: PtrVector.h:301
friend bool operator!=(const ConstCastIterator< L > &lhs, const CastIterator< R > &rhs)
Inequality comparison between a ConstCastIterator and a CastIterator.
Definition: PtrVector.h:558
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:352
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:4584
friend bool operator==(const ConstCastIterator< L > &lhs, const CastIterator< R > &rhs)
Equality comparison between a ConstCastIterator and a CastIterator.
Definition: PtrVector.h:502
Iterator erase(Iterator pos)
Removing an element from the pointer vector.
Definition: PtrVector.h:1469
T * ValueType
Type of the underlying values.
Definition: PtrVector.h:294
ValueType value_type
Type of the underlying pointers.
Definition: PtrVector.h:1980
PointerType * end_
Pointer to the last element of the pointer vector.
Definition: PtrVector.h:454
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2378
PointerType * begin_
Pointer to the first element of the pointer vector.
Definition: PtrVector.h:453
Implementation of a vector for (polymorphic) pointers.
Definition: PtrVector.h:282
IteratorType end_
Pointer to the element one past the last element in the element range.
Definition: PtrVector.h:2372
const IteratorType & base() const
Direct access to the current memory location of the cast iterator.
Definition: PtrVector.h:2235
T *const & ConstReferenceType
Reference to a const object.
Definition: PtrVector.h:298
D DeletionPolicy
Type of the deletion policy.
Definition: PtrVector.h:302
C * ValueType
Type of the underlying pointers.
Definition: PtrVector.h:1972
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:2514
const T *const * IteratorType
Type of the internal pointer.
Definition: PtrVector.h:2309
const T * ConstPointerType
Pointer to a const object.
Definition: PtrVector.h:296
ReferenceType front()
Returns a reference to the first element of the pointer vector.
Definition: PtrVector.h:924
size_t calcCapacity(size_t minCapacity) const
Calculating the new capacity of the vector based on its growth policy.
Definition: PtrVector.h:1663
T *& ReferenceType
Reference to a non-const object.
Definition: PtrVector.h:297
ConstPointerType const_pointer
Pointer to a const object.
Definition: PtrVector.h:308
friend bool operator!=(const CastIterator< L > &lhs, const CastIterator< R > &rhs)
Inequality comparison between two CastIterator objects.
Definition: PtrVector.h:530
SizeType maxSize() const
Returns the maximum possible size of a pointer vector.
Definition: PtrVector.h:769
const C * ValueType
Type of the underlying pointers.
Definition: PtrVector.h:2305
void popBack()
Removing an element from the end of the pointer vector.
Definition: PtrVector.h:1319
IteratorCategory iterator_category
The iterator category.
Definition: PtrVector.h:2312
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Header file for basic type definitions.
PtrVector & operator=(const PtrVector &pv)
Copy assignment operator for PtrVector.
Definition: PtrVector.h:697
void swap(PtrVector &pv)
Swapping the contents of two pointer vectors.
Definition: PtrVector.h:1634
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
Header file for the OptimalGrowth policy classes.
void deleteElement(PointerType ptr) const
Deleting an element of the pointer vector according to the deletion policy.
Definition: PtrVector.h:1682
Size type of the Blaze library.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
SizeType size_
The current size of the pointer vector.
Definition: PtrVector.h:451
const IteratorType & base() const
Access to the underlying member of the pointer iterator.
Definition: PtrIterator.h:434
PtrIterator< T > Iterator
Iterator over non-const objects.
Definition: PtrVector.h:300
DifferenceType difference_type
Difference between two iterators.
Definition: PtrVector.h:1983