35 #ifndef _BLAZE_UTIL_PTRVECTOR_H_
36 #define _BLAZE_UTIL_PTRVECTOR_H_
279 ,
typename D = PtrDelete
280 ,
typename G = OptimalGrowth >
286 template<
typename T2,
typename D2,
typename G2 >
friend class PtrVector;
321 explicit inline PtrVector( SizeType initCapacity = 0 );
324 template<
typename T2,
typename D2,
typename G2 >
341 template<
typename T2,
typename D2,
typename G2 >
349 inline SizeType
maxSize()
const;
350 inline SizeType
size()
const;
351 template<
typename C >
inline SizeType
size()
const;
360 inline ReferenceType
operator[]( SizeType index );
361 inline ConstReferenceType
operator[]( SizeType index )
const;
362 inline ReferenceType
front();
363 inline ConstReferenceType
front()
const;
364 inline ReferenceType
back();
365 inline ConstReferenceType
back()
const;
372 inline Iterator
begin();
373 inline ConstIterator
begin()
const;
377 inline Iterator
end();
378 inline ConstIterator
end()
const;
387 inline void pushBack ( PointerType p );
391 template<
typename IteratorType >
394 inline Iterator
insert( Iterator pos, PointerType p );
396 template<
typename IteratorType >
400 template<
typename IteratorType >
404 inline Iterator
erase ( Iterator pos );
406 inline Iterator
release( Iterator pos );
408 inline void clear ();
415 void reserve( SizeType newCapacity );
424 inline size_t calcCapacity (
size_t minCapacity )
const;
432 void insert( T**
const pos, PointerType p );
435 template<
typename IteratorType >
438 template<
typename IteratorType >
442 template<
typename IteratorType >
472 template<
typename L,
typename R >
473 friend inline bool operator==(
const CastIterator<L>& lhs,
const CastIterator<R>& rhs )
475 return lhs.base() == rhs.base();
486 template<
typename L,
typename R >
487 friend inline bool operator==(
const CastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
489 return lhs.base() == rhs.base();
500 template<
typename L,
typename R >
501 friend inline bool operator==(
const ConstCastIterator<L>& lhs,
const CastIterator<R>& rhs )
503 return lhs.base() == rhs.base();
514 template<
typename L,
typename R >
515 friend inline bool operator==(
const ConstCastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
517 return lhs.base() == rhs.base();
528 template<
typename L,
typename R >
529 friend inline bool operator!=(
const CastIterator<L>& lhs,
const CastIterator<R>& rhs )
531 return lhs.base() != rhs.base();
542 template<
typename L,
typename R >
543 friend inline bool operator!=(
const CastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
545 return lhs.base() != rhs.base();
556 template<
typename L,
typename R >
557 friend inline bool operator!=(
const ConstCastIterator<L>& lhs,
const CastIterator<R>& rhs )
559 return lhs.base() != rhs.base();
570 template<
typename L,
typename R >
571 friend inline bool operator!=(
const ConstCastIterator<L>& lhs,
const ConstCastIterator<R>& rhs )
573 return lhs.base() != rhs.base();
638 template<
typename T2
673 deleteElement( *it );
698 if( &pv ==
this )
return *
this;
728 template<
typename T2
821 template<
typename C >
925 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the front element" );
943 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the front element" );
961 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the back element" );
979 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the back element" );
1013 template<
typename T
1068 template<
typename T
1071 template<
typename C >
1124 template<
typename T
1127 template<
typename C >
1140 template<
typename T
1155 template<
typename T
1207 template<
typename T
1210 template<
typename C >
1213 return CastIterator<C>(
end_,
end_ );
1260 template<
typename T
1263 template<
typename C >
1266 return ConstCastIterator<C>(
end_,
end_ );
1288 template<
typename T
1315 template<
typename T
1320 deleteElement( *--
end_ );
1336 template<
typename T
1359 template<
typename T
1362 template<
typename IteratorType >
1366 insert(
end(), first, last );
1382 template<
typename T
1387 T**
const base =
const_cast<T**
>( pos.
base() );
1417 template<
typename T
1420 template<
typename IteratorType >
1423 insert( pos, first, last,
typename IteratorType::iterator_category() );
1442 template<
typename T
1445 template<
typename IteratorType >
1448 insert( pos, first, last, std::random_access_iterator_tag() );
1465 template<
typename T
1470 T**
const base =
const_cast<T**
>( pos.
base() );
1471 deleteElement( *base );
1472 std::copy( base+1,
end_, base );
1493 template<
typename T
1496 template<
typename C >
1500 T**
const base =
const_cast<T**
>( pos.
base() );
1501 deleteElement( *base );
1502 std::copy( base+1,
end_, base );
1522 template<
typename T
1527 T**
const base =
const_cast<T**
>( pos.
base() );
1528 std::copy( base+1,
end_, base );
1548 template<
typename T
1551 template<
typename C >
1555 T**
const base =
const_cast<T**
>( pos.
base() );
1556 std::copy( base+1,
end_, base );
1571 template<
typename T
1577 deleteElement( *it );
1599 template<
typename T
1607 newCapacity = calcCapacity( newCapacity );
1630 template<
typename T
1659 template<
typename T
1678 template<
typename T
1704 template<
typename T
1710 std::copy_backward( pos,
end_,
end_+1 );
1715 else if( size_ == maxSize() ) {
1720 if( newCapacity > maxSize() || newCapacity <
capacity_ ) newCapacity = maxSize();
1726 end_ = std::copy( pos,
end_, newEnd );
1750 template<
typename T
1753 template<
typename IteratorType >
1755 std::input_iterator_tag )
1757 for( ; first!=last; ++first ) {
1758 pos = insert( pos, *first );
1779 template<
typename T
1782 template<
typename IteratorType >
1784 std::random_access_iterator_tag )
1786 T**
const base =
const_cast<T**
>( pos.base() );
1787 const SizeType diff( last - first );
1790 for( ; first!=last; ++first, ++
end_ ) {
1796 insert( base, first, last, diff );
1813 template<
typename T
1816 template<
typename IteratorType >
1819 const SizeType newSize( size_ + n );
1822 std::copy_backward( pos,
end_,
end_+n );
1823 for( ; first!=last; ++first, ++pos ) {
1829 else if( newSize > maxSize() || newSize < size_ ) {
1836 for( ; first!=last; ++first, ++newEnd ) {
1840 end_ = std::copy( pos,
end_, newEnd );
1862 template<
typename T,
typename D,
typename G >
1865 template<
typename T,
typename D,
typename G >
1868 template<
typename T,
typename D,
typename G >
1881 template<
typename T
1898 template<
typename T
1916 template<
typename T
1961 template<
typename T
1964 template<
typename C >
1965 class PtrVector<T,D,G>::CastIterator
1991 template<
typename Other >
2018 inline PointerType operator->()
const;
2025 inline const IteratorType& base()
const;
2026 inline const IteratorType& stop()
const;
2053 template<
typename T
2056 template<
typename C >
2072 template<
typename T
2075 template<
typename C >
2097 template<
typename T
2100 template<
typename C >
2101 template<
typename Other >
2125 template<
typename T
2128 template<
typename C >
2139 cur_ = polymorphicFind<C>( ++cur_,
end_ );
2151 template<
typename T
2154 template<
typename C >
2167 cur_ = polymorphicFind<C>( ++cur_,
end_ );
2187 template<
typename T
2190 template<
typename C >
2194 return static_cast<C*
>( *cur_ );
2204 template<
typename T
2207 template<
typename C >
2211 return static_cast<C*
>( *cur_ );
2229 template<
typename T
2232 template<
typename C >
2246 template<
typename T
2249 template<
typename C >
2294 template<
typename T
2297 template<
typename C >
2324 template<
typename Other >
2327 template<
typename Other >
2354 inline PointerType operator->()
const;
2361 inline const IteratorType& base()
const;
2362 inline const IteratorType& stop()
const;
2389 template<
typename T
2392 template<
typename C >
2408 template<
typename T
2411 template<
typename C >
2433 template<
typename T
2436 template<
typename C >
2437 template<
typename Other >
2453 template<
typename T
2456 template<
typename C >
2457 template<
typename Other >
2481 template<
typename T
2484 template<
typename C >
2495 cur_ = polymorphicFind<const C>( ++cur_,
end_ );
2507 template<
typename T
2510 template<
typename C >
2523 cur_ = polymorphicFind<const C>( ++cur_,
end_ );
2543 template<
typename T
2546 template<
typename C >
2550 return static_cast<const C*
>( *cur_ );
2560 template<
typename T
2563 template<
typename C >
2567 return static_cast<const C*
>( *cur_ );
2585 template<
typename T
2588 template<
typename C >
2602 template<
typename T
2605 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:2315
void assign(IteratorType first, IteratorType last)
Assigning a range of elements to the pointer vector.
Definition: PtrVector.h:1363
friend bool operator==(const CastIterator< L > &lhs, const CastIterator< R > &rhs)
Equality comparison between two CastIterator objects.
Definition: PtrVector.h:473
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:7800
ReferenceType reference
Reference return type.
Definition: PtrVector.h:1981
Header file for basic type definitions.
IteratorType cur_
Pointer to the current memory location.
Definition: PtrVector.h:2370
ReferenceType reference
Reference to a non-const object.
Definition: PtrVector.h:308
friend bool operator!=(const ConstCastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Inequality comparison between two ConstCastIterator objects.
Definition: PtrVector.h:571
ConstReferenceType const_reference
Reference to a const object.
Definition: PtrVector.h:309
IteratorType end_
Pointer to the element one past the last element in the element range.
Definition: PtrVector.h:2035
Iterator insert(Iterator pos, PointerType p)
Inserting an element into the pointer vector.
Definition: PtrVector.h:1385
ReferenceType operator[](SizeType index)
Subscript operator for the direct access to the pointer vector elements.
Definition: PtrVector.h:888
Iterator begin()
Returns an iterator to the beginning of the pointer vector.
Definition: PtrVector.h:1001
void pushBack(PointerType p)
Adding an element to the end of the pointer vector.
Definition: PtrVector.h:1291
#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:60
Header file for exception macros.
void releaseBack()
Releasing the element at the end of the pointer vector.
Definition: PtrVector.h:1339
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: PtrVector.h:1974
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: PtrVector.h:1970
Iterator class for pointer vectors.
Iterator end()
Returns an iterator just past the last element of the pointer vector.
Definition: PtrVector.h:1143
#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:101
size_t SizeType
Size type of the pointer vector.
Definition: PtrVector.h:298
T *const * IteratorType
Type of the internal pointer.
Definition: PtrVector.h:1975
G GrowthPolicy
Type of the growth policy.
Definition: PtrVector.h:302
SizeType size_type
Size type of the pointer vector.
Definition: PtrVector.h:310
#define BLAZE_THROW_LENGTH_ERROR(MESSAGE)
Macro for the emission of a std::length_error exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:283
void clear()
Removing all elements from the pointer vector.
Definition: PtrVector.h:1574
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2807
friend bool operator!=(const CastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Inequality comparison between a CastIterator and a ConstCastIterator.
Definition: PtrVector.h:543
~PtrVector()
Destructor for PtrVector.
Definition: PtrVector.h:670
C *const & ReferenceType
Reference return type.
Definition: PtrVector.h:1973
SizeType capacity() const
Returns the capacity of the pointer vector.
Definition: PtrVector.h:847
Header file for the PtrDelete policy classes.
IteratorCategory iterator_category
The iterator category.
Definition: PtrVector.h:1978
IteratorType cur_
Pointer to the current memory location.
Definition: PtrVector.h:2034
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Dynamic cast iterator for polymorphic pointer vectors.The ConstCastIterator class is part of the PtrV...
Definition: PtrVector.h:315
ReferenceType back()
Returns a reference to the last element of the pointer vector.
Definition: PtrVector.h:959
T * PointerType
Pointer to a non-const object.
Definition: PtrVector.h:294
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
PointerType pointer
Pointer return type.
Definition: PtrVector.h:1980
Constraint on the pointer relationship.
PtrVector(SizeType initCapacity=0)
Standard constructor for PtrVector.
Definition: PtrVector.h:601
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:2809
ValueType value_type
Type of the underlying pointers.
Definition: PtrVector.h:2312
ValueType value_type
Type of the underlying values.
Definition: PtrVector.h:305
friend bool operator==(const CastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Equality comparison between a CastIterator and a ConstCastIterator.
Definition: PtrVector.h:487
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: PtrVector.h:2303
C * PointerType
Pointer return type.
Definition: PtrVector.h:1972
friend bool operator==(const ConstCastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Equality comparison between two ConstCastIterator objects.
Definition: PtrVector.h:515
Constraint on the inheritance relationship of a data type.
const C *const & ReferenceType
Reference return type.
Definition: PtrVector.h:2306
Iterator release(Iterator pos)
Releasing an element from the pointer vector.
Definition: PtrVector.h:1525
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: PtrVector.h:2307
ReferenceType reference
Reference return type.
Definition: PtrVector.h:2314
PointerType pointer
Pointer return type.
Definition: PtrVector.h:2313
const C * PointerType
Pointer return type.
Definition: PtrVector.h:2305
bool isEmpty() const
Returns true if the pointer vector has no elements.
Definition: PtrVector.h:862
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Headerfile for generic algorithms.
Implementation of an iterator for pointer vectors.The PtrIterator class follows the example of the ra...
Definition: PtrIterator.h:107
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
PointerType pointer
Pointer to a non-const object.
Definition: PtrVector.h:306
Dynamic cast iterator for polymorphic pointer vectors.The CastIterator class is part of the PtrVector...
Definition: PtrVector.h:314
void reserve(SizeType newCapacity)
Setting the minimum capacity of the pointer vector.
Definition: PtrVector.h:1602
SizeType capacity_
The capacity of the pointer vector.
Definition: PtrVector.h:451
SizeType size() const
Returns the current size of the pointer vector.
Definition: PtrVector.h:783
Header file for run time assertion macros.
PtrIterator< const T > ConstIterator
Iterator over const objects.
Definition: PtrVector.h:300
friend bool operator!=(const ConstCastIterator< L > &lhs, const CastIterator< R > &rhs)
Inequality comparison between a ConstCastIterator and a CastIterator.
Definition: PtrVector.h:557
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:73
friend bool operator==(const ConstCastIterator< L > &lhs, const CastIterator< R > &rhs)
Equality comparison between a ConstCastIterator and a CastIterator.
Definition: PtrVector.h:501
Iterator erase(Iterator pos)
Removing an element from the pointer vector.
Definition: PtrVector.h:1468
T * ValueType
Type of the underlying values.
Definition: PtrVector.h:293
ValueType value_type
Type of the underlying pointers.
Definition: PtrVector.h:1979
PointerType * end_
Pointer to the last element of the pointer vector.
Definition: PtrVector.h:453
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
PointerType * begin_
Pointer to the first element of the pointer vector.
Definition: PtrVector.h:452
Implementation of a vector for (polymorphic) pointers.
Definition: PtrVector.h:281
IteratorType end_
Pointer to the element one past the last element in the element range.
Definition: PtrVector.h:2371
const IteratorType & base() const
Direct access to the current memory location of the cast iterator.
Definition: PtrVector.h:2234
T *const & ConstReferenceType
Reference to a const object.
Definition: PtrVector.h:297
D DeletionPolicy
Type of the deletion policy.
Definition: PtrVector.h:301
C * ValueType
Type of the underlying pointers.
Definition: PtrVector.h:1971
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:2808
const T *const * IteratorType
Type of the internal pointer.
Definition: PtrVector.h:2308
const T * ConstPointerType
Pointer to a const object.
Definition: PtrVector.h:295
ReferenceType front()
Returns a reference to the first element of the pointer vector.
Definition: PtrVector.h:923
size_t calcCapacity(size_t minCapacity) const
Calculating the new capacity of the vector based on its growth policy.
Definition: PtrVector.h:1662
T *& ReferenceType
Reference to a non-const object.
Definition: PtrVector.h:296
ConstPointerType const_pointer
Pointer to a const object.
Definition: PtrVector.h:307
friend bool operator!=(const CastIterator< L > &lhs, const CastIterator< R > &rhs)
Inequality comparison between two CastIterator objects.
Definition: PtrVector.h:529
SizeType maxSize() const
Returns the maximum possible size of a pointer vector.
Definition: PtrVector.h:768
const C * ValueType
Type of the underlying pointers.
Definition: PtrVector.h:2304
void popBack()
Removing an element from the end of the pointer vector.
Definition: PtrVector.h:1318
IteratorCategory iterator_category
The iterator category.
Definition: PtrVector.h:2311
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
void swap(PtrVector &pv) noexcept
Swapping the contents of two pointer vectors.
Definition: PtrVector.h:1633
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
PtrVector & operator=(const PtrVector &pv)
Copy assignment operator for PtrVector.
Definition: PtrVector.h:696
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:1681
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:450
const IteratorType & base() const
Access to the underlying member of the pointer iterator.
Definition: PtrIterator.h:433
PtrIterator< T > Iterator
Iterator over non-const objects.
Definition: PtrVector.h:299
DifferenceType difference_type
Difference between two iterators.
Definition: PtrVector.h:1982