PtrVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_PTRVECTOR_H_
36 #define _BLAZE_UTIL_PTRVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <blaze/util/Algorithm.h>
45 #include <blaze/util/Assert.h>
48 #include <blaze/util/Exception.h>
51 #include <blaze/util/PtrIterator.h>
52 #include <blaze/util/Template.h>
53 #include <blaze/util/Types.h>
54 
55 
56 namespace blaze {
57 
58 //=================================================================================================
59 //
60 // CLASS DEFINITION
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
278 template< typename T // Type
279  , typename D = PtrDelete // Deletion policy
280  , typename G = OptimalGrowth > // Growth policy
282 {
283  private:
284  //**Friend declarations*************************************************************************
286  template< typename T2, typename D2, typename G2 > friend class PtrVector;
288  //**********************************************************************************************
289 
290  public:
291  //**Type definitions****************************************************************************
292  // Blaze naming convention
293  typedef T* ValueType;
294  typedef T* PointerType;
295  typedef const T* ConstPointerType;
296  typedef T*& ReferenceType;
297  typedef T*const& ConstReferenceType;
298  typedef size_t SizeType;
301  typedef D DeletionPolicy;
302  typedef G GrowthPolicy;
303 
304  // STL iterator requirements
305  typedef ValueType value_type;
306  typedef PointerType pointer;
307  typedef ConstPointerType const_pointer;
308  typedef ReferenceType reference;
309  typedef ConstReferenceType const_reference;
310  typedef SizeType size_type;
311  //**********************************************************************************************
312 
313  //**Forward declarations for nested classes*****************************************************
314  template< typename C > class CastIterator;
315  template< typename C > class ConstCastIterator;
316  //**********************************************************************************************
317 
318  //**Constructors********************************************************************************
321  explicit inline PtrVector( SizeType initCapacity = 0 );
322  inline PtrVector( const PtrVector& pv );
323 
324  template< typename T2, typename D2, typename G2 >
325  inline PtrVector( const PtrVector<T2,D2,G2>& pv );
327  //**********************************************************************************************
328 
329  //**Destructor**********************************************************************************
332  inline ~PtrVector();
334  //**********************************************************************************************
335 
336  //**Assignment operators************************************************************************
339  PtrVector& operator=( const PtrVector& pv );
340 
341  template< typename T2, typename D2, typename G2 >
344  //**********************************************************************************************
345 
346  //**Get functions*******************************************************************************
349  inline SizeType maxSize() const;
350  inline SizeType size() const;
351  template< typename C > inline SizeType size() const;
352  inline SizeType capacity() const;
353  inline bool isEmpty() const;
355  //**********************************************************************************************
356 
357  //**Access functions****************************************************************************
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;
367  //**********************************************************************************************
368 
369  //**Iterator functions**************************************************************************
372  inline Iterator begin();
373  inline ConstIterator begin() const;
374  template< typename C > inline CastIterator<C> begin();
375  template< typename C > inline ConstCastIterator<C> begin() const;
376 
377  inline Iterator end();
378  inline ConstIterator end() const;
379  template< typename C > inline CastIterator<C> end();
380  template< typename C > inline ConstCastIterator<C> end() const;
382  //**********************************************************************************************
383 
384  //**Element functions***************************************************************************
387  inline void pushBack ( PointerType p );
388  inline void popBack ();
389  inline void releaseBack();
390 
391  template< typename IteratorType >
392  inline void assign( IteratorType first, IteratorType last );
393 
394  inline Iterator insert( Iterator pos, PointerType p );
395 
396  template< typename IteratorType >
397  inline void insert( Iterator pos, IteratorType first, IteratorType last );
398 
400  template< typename IteratorType >
401  inline void insert( Iterator pos, IteratorType* first, IteratorType* last );
404  inline Iterator erase ( Iterator pos );
405  template< typename C > inline CastIterator<C> erase ( CastIterator<C> pos );
406  inline Iterator release( Iterator pos );
407  template< typename C > inline CastIterator<C> release( CastIterator<C> pos );
408  inline void clear ();
410  //**********************************************************************************************
411 
412  //**Utility functions***************************************************************************
415  void reserve( SizeType newCapacity );
416  inline void swap( PtrVector& pv ) noexcept;
418  //**********************************************************************************************
419 
420  private:
421  //**Helper functions****************************************************************************
424  inline size_t calcCapacity ( size_t minCapacity ) const;
425  inline void deleteElement( PointerType ptr ) const;
427  //**********************************************************************************************
428 
429  //**Insertion helper functions******************************************************************
432  void insert( T**const pos, PointerType p );
433 
435  template< typename IteratorType >
436  inline void insert( Iterator pos, IteratorType first, IteratorType last, std::input_iterator_tag );
437 
438  template< typename IteratorType >
439  inline void insert( Iterator pos, IteratorType first, IteratorType last, std::random_access_iterator_tag );
442  template< typename IteratorType >
443  void insert( T** pos, IteratorType first, IteratorType last, SizeType n );
445  //**********************************************************************************************
446 
447  //**Member variables****************************************************************************
450  SizeType size_;
451  SizeType capacity_;
452  PointerType* begin_;
453  PointerType* end_;
454 
455  //**********************************************************************************************
456 
457  public:
458  //**CastIterator/ConstCastIterator comparison operators*****************************************
459  // The following comparison operators cannot be defined as namespace or member functions
460  // but have to be injected into the surrounding scope via the Barton-Nackman trick since
461  // the template arguments of nested templates cannot be deduced (C++ standard 14.8.2.4/4).
464 
465  //**********************************************************************************************
472  template< typename L, typename R >
473  friend inline bool operator==( const CastIterator<L>& lhs, const CastIterator<R>& rhs )
474  {
475  return lhs.base() == rhs.base();
476  }
477  //**********************************************************************************************
478 
479  //**********************************************************************************************
486  template< typename L, typename R >
487  friend inline bool operator==( const CastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
488  {
489  return lhs.base() == rhs.base();
490  }
491  //**********************************************************************************************
492 
493  //**********************************************************************************************
500  template< typename L, typename R >
501  friend inline bool operator==( const ConstCastIterator<L>& lhs, const CastIterator<R>& rhs )
502  {
503  return lhs.base() == rhs.base();
504  }
505  //**********************************************************************************************
506 
507  //**********************************************************************************************
514  template< typename L, typename R >
515  friend inline bool operator==( const ConstCastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
516  {
517  return lhs.base() == rhs.base();
518  }
519  //**********************************************************************************************
520 
521  //**********************************************************************************************
528  template< typename L, typename R >
529  friend inline bool operator!=( const CastIterator<L>& lhs, const CastIterator<R>& rhs )
530  {
531  return lhs.base() != rhs.base();
532  }
533  //**********************************************************************************************
534 
535  //**********************************************************************************************
542  template< typename L, typename R >
543  friend inline bool operator!=( const CastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
544  {
545  return lhs.base() != rhs.base();
546  }
547  //**********************************************************************************************
548 
549  //**********************************************************************************************
556  template< typename L, typename R >
557  friend inline bool operator!=( const ConstCastIterator<L>& lhs, const CastIterator<R>& rhs )
558  {
559  return lhs.base() != rhs.base();
560  }
561  //**********************************************************************************************
562 
563  //**********************************************************************************************
570  template< typename L, typename R >
571  friend inline bool operator!=( const ConstCastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
572  {
573  return lhs.base() != rhs.base();
574  }
575  //**********************************************************************************************
576 
578  //**********************************************************************************************
579 };
580 //*************************************************************************************************
581 
582 
583 
584 
585 //=================================================================================================
586 //
587 // CONSTRUCTORS
588 //
589 //=================================================================================================
590 
591 //*************************************************************************************************
598 template< typename T // Type
599  , typename D // Deletion policy
600  , typename G > // Growth policy
601 inline PtrVector<T,D,G>::PtrVector( SizeType initCapacity )
602  : size_( 0 ) // Current size of the pointer vector
603  , capacity_( initCapacity ) // Capacity of the pointer vector
604  , begin_( new PointerType[initCapacity] ) // Pointer to the first element
605  , end_( begin_ ) // Pointer to the last element
606 {}
607 //*************************************************************************************************
608 
609 
610 //*************************************************************************************************
615 template< typename T // Type
616  , typename D // Deletion policy
617  , typename G > // Growth policy
619  : size_( pv.size_ ) // Current size of the pointer vector
620  , capacity_( pv.size_ ) // Capacity of the pointer vector
621  , begin_( new PointerType[capacity_] ) // Pointer to the first element
622  , end_( begin_+size_ ) // Pointer to the last element
623 {
624  for( SizeType i=0; i<size_; ++i )
625  begin_[i] = pv.begin_[i];
626 }
627 //*************************************************************************************************
628 
629 
630 //*************************************************************************************************
635 template< typename T // Type of the pointer vector
636  , typename D // Deletion policy of the pointer vector
637  , typename G > // Growth policy of the pointer vector
638 template< typename T2 // Type of the foreign pointer vector
639  , typename D2 // Deletion policy of the foreign pointer vector
640  , typename G2 > // Growth policy of the foreign pointer vector
642  : size_( pv.size_ ) // Current size of the pointer vector
643  , capacity_( pv.size_ ) // Capacity of the pointer vector
644  , begin_( new PointerType[capacity_] ) // Pointer to the first element
645  , end_( begin_+size_ ) // Pointer to the last element
646 {
647  for( SizeType i=0; i<size_; ++i )
648  begin_[i] = pv.begin_[i];
649 }
650 //*************************************************************************************************
651 
652 
653 
654 
655 //=================================================================================================
656 //
657 // DESTRUCTOR
658 //
659 //=================================================================================================
660 
661 //*************************************************************************************************
667 template< typename T // Type
668  , typename D // Deletion policy
669  , typename G > // Growth policy
671 {
672  for( PointerType* it=begin_; it!=end_; ++it )
673  deleteElement( *it );
674  delete [] begin_;
675 }
676 //*************************************************************************************************
677 
678 
679 
680 
681 //=================================================================================================
682 //
683 // ASSIGNMENT OPERATORS
684 //
685 //=================================================================================================
686 
687 //*************************************************************************************************
693 template< typename T // Type
694  , typename D // Deletion policy
695  , typename G > // Growth policy
697 {
698  if( &pv == this ) return *this;
699 
700  if( pv.size_ > capacity_ ) {
701  PointerType* newBegin( new PointerType[pv.size_] );
702  end_ = std::copy( pv.begin_, pv.end_, newBegin );
703  std::swap( begin_, newBegin );
704  delete [] newBegin;
705 
706  size_ = pv.size_;
707  capacity_ = pv.size_;
708  }
709  else {
710  end_ = std::copy( pv.begin_, pv.end_, begin_ );
711  size_ = pv.size_;
712  }
713 
714  return *this;
715 }
716 //*************************************************************************************************
717 
718 
719 //*************************************************************************************************
725 template< typename T // Type of the pointer vector
726  , typename D // Deletion policy of the pointer vector
727  , typename G > // Growth policy of the pointer vector
728 template< typename T2 // Type of the foreign pointer vector
729  , typename D2 // Deletion policy of the foreign pointer vector
730  , typename G2 > // Growth policy of the foreign pointer vector
732 {
733  if( pv.size_ > capacity_ ) {
734  PointerType* newBegin( new PointerType[pv.size_] );
735  end_ = std::copy( pv.begin_, pv.end_, newBegin );
736  std::swap( begin_, newBegin );
737  delete [] newBegin;
738 
739  size_ = pv.size_;
740  capacity_ = pv.size_;
741  }
742  else {
743  end_ = std::copy( pv.begin_, pv.end_, begin_ );
744  size_ = pv.size_;
745  }
746 
747  return *this;
748 }
749 //*************************************************************************************************
750 
751 
752 
753 
754 //=================================================================================================
755 //
756 // GET FUNCTIONS
757 //
758 //=================================================================================================
759 
760 //*************************************************************************************************
765 template< typename T // Type
766  , typename D // Deletion policy
767  , typename G > // Growth policy
769 {
770  return SizeType(-1) / sizeof(PointerType);
771 }
772 //*************************************************************************************************
773 
774 
775 //*************************************************************************************************
780 template< typename T // Type
781  , typename D // Deletion policy
782  , typename G > // Growth policy
784 {
785  return size_;
786 }
787 //*************************************************************************************************
788 
789 
790 //*************************************************************************************************
818 template< typename T // Type
819  , typename D // Deletion policy
820  , typename G > // Growth policy
821 template< typename C > // Cast type
823 {
824  // The polymorphicCount() function returns the number of objects with dynamic type 'C'
825  // contained in the range [begin,end). An equivalent code might look like this:
826  //
827  // SizeType count( 0 );
828  // for( PointerType* it=begin_; it!=end_; ++it )
829  // if( dynamic_cast<C*>( *it ) ) ++count;
830  // return count;
831  //
832  // However, the specialization of polymorphicCount() for special type combinations is
833  // much more efficient (and easier) than the specialization of this function!
834  return polymorphicCount<C>( begin_, end_ );
835 }
836 //*************************************************************************************************
837 
838 
839 //*************************************************************************************************
844 template< typename T // Type
845  , typename D // Deletion policy
846  , typename G > // Growth policy
848 {
849  return capacity_;
850 }
851 //*************************************************************************************************
852 
853 
854 //*************************************************************************************************
859 template< typename T // Type
860  , typename D // Deletion policy
861  , typename G > // Growth policy
862 inline bool PtrVector<T,D,G>::isEmpty() const
863 {
864  return size_ == 0;
865 }
866 //*************************************************************************************************
867 
868 
869 
870 
871 //=================================================================================================
872 //
873 // ACCESS FUNCTIONS
874 //
875 //=================================================================================================
876 
877 //*************************************************************************************************
885 template< typename T // Type
886  , typename D // Deletion policy
887  , typename G > // Growth policy
889 {
890  return *(begin_+index);
891 }
892 //*************************************************************************************************
893 
894 
895 //*************************************************************************************************
903 template< typename T // Type
904  , typename D // Deletion policy
905  , typename G > // Growth policy
907 {
908  return *(begin_+index);
909 }
910 //*************************************************************************************************
911 
912 
913 //*************************************************************************************************
920 template< typename T // Type
921  , typename D // Deletion policy
922  , typename G > // Growth policy
924 {
925  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the front element" );
926  return *begin_;
927 }
928 //*************************************************************************************************
929 
930 
931 //*************************************************************************************************
938 template< typename T // Type
939  , typename D // Deletion policy
940  , typename G > // Growth policy
942 {
943  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the front element" );
944  return *begin_;
945 }
946 //*************************************************************************************************
947 
948 
949 //*************************************************************************************************
956 template< typename T // Type
957  , typename D // Deletion policy
958  , typename G > // Growth policy
960 {
961  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the back element" );
962  return *(end_-1);
963 }
964 //*************************************************************************************************
965 
966 
967 //*************************************************************************************************
974 template< typename T // Type
975  , typename D // Deletion policy
976  , typename G > // Growth policy
978 {
979  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the back element" );
980  return *(end_-1);
981 }
982 //*************************************************************************************************
983 
984 
985 
986 
987 //=================================================================================================
988 //
989 // ITERATOR FUNCTIONS
990 //
991 //=================================================================================================
992 
993 //*************************************************************************************************
998 template< typename T // Type
999  , typename D // Deletion policy
1000  , typename G > // Growth policy
1002 {
1003  return Iterator( begin_ );
1004 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1013 template< typename T // Type
1014  , typename D // Deletion policy
1015  , typename G > // Growth policy
1017 {
1018  return ConstIterator( begin_ );
1019 }
1020 //*************************************************************************************************
1021 
1022 
1023 //*************************************************************************************************
1068 template< typename T // Type
1069  , typename D // Deletion policy
1070  , typename G > // Growth policy
1071 template< typename C > // Cast type
1072 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C> PtrVector<T,D,G>::begin()
1073 {
1074  return CastIterator<C>( begin_, end_ );
1075 }
1076 //*************************************************************************************************
1077 
1078 
1079 //*************************************************************************************************
1124 template< typename T // Type
1125  , typename D // Deletion policy
1126  , typename G > // Growth policy
1127 template< typename C > // Cast type
1128 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE ConstCastIterator<C> PtrVector<T,D,G>::begin() const
1129 {
1130  return ConstCastIterator<C>( begin_, end_ );
1131 }
1132 //*************************************************************************************************
1133 
1134 
1135 //*************************************************************************************************
1140 template< typename T // Type
1141  , typename D // Deletion policy
1142  , typename G > // Growth policy
1144 {
1145  return Iterator( end_ );
1146 }
1147 //*************************************************************************************************
1148 
1149 
1150 //*************************************************************************************************
1155 template< typename T // Type
1156  , typename D // Deletion policy
1157  , typename G > // Growth policy
1159 {
1160  return ConstIterator( end_ );
1161 }
1162 //*************************************************************************************************
1163 
1164 
1165 //*************************************************************************************************
1207 template< typename T // Type
1208  , typename D // Deletion policy
1209  , typename G > // Growth policy
1210 template< typename C > // Cast type
1211 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C> PtrVector<T,D,G>::end()
1212 {
1213  return CastIterator<C>( end_, end_ );
1214 }
1215 //*************************************************************************************************
1216 
1217 
1218 //*************************************************************************************************
1260 template< typename T // Type
1261  , typename D // Deletion policy
1262  , typename G > // Growth policy
1263 template< typename C > // Cast type
1264 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE ConstCastIterator<C> PtrVector<T,D,G>::end() const
1265 {
1266  return ConstCastIterator<C>( end_, end_ );
1267 }
1268 //*************************************************************************************************
1269 
1270 
1271 
1272 
1273 //=================================================================================================
1274 //
1275 // ELEMENT FUNCTIONS
1276 //
1277 //=================================================================================================
1278 
1279 //*************************************************************************************************
1288 template< typename T // Type
1289  , typename D // Deletion policy
1290  , typename G > // Growth policy
1292 {
1293  if( size_ != capacity_ ) {
1294  *end_ = p;
1295  ++end_;
1296  ++size_;
1297  }
1298  else {
1299  insert( end_, p );
1300  }
1301 }
1302 //*************************************************************************************************
1303 
1304 
1305 //*************************************************************************************************
1315 template< typename T // Type
1316  , typename D // Deletion policy
1317  , typename G > // Growth policy
1319 {
1320  deleteElement( *--end_ );
1321  --size_;
1322 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1336 template< typename T // Type
1337  , typename D // Deletion policy
1338  , typename G > // Growth policy
1340 {
1341  --end_;
1342  --size_;
1343 }
1344 //*************************************************************************************************
1345 
1346 
1347 //*************************************************************************************************
1359 template< typename T // Type
1360  , typename D // Deletion policy
1361  , typename G > // Growth policy
1362 template< typename IteratorType >
1363 inline void PtrVector<T,D,G>::assign( IteratorType first, IteratorType last )
1364 {
1365  clear();
1366  insert( end(), first, last );
1367 }
1368 //*************************************************************************************************
1369 
1370 
1371 //*************************************************************************************************
1382 template< typename T // Type
1383  , typename D // Deletion policy
1384  , typename G > // Growth policy
1386 {
1387  T** const base = const_cast<T**>( pos.base() );
1388  const SizeType diff( base - begin_ );
1389 
1390  if( size_ != capacity_ && base == end_ ) {
1391  *end_ = p;
1392  ++end_;
1393  ++size_;
1394  }
1395  else {
1396  insert( base, p );
1397  }
1398 
1399  return Iterator( begin_+diff );
1400 }
1401 //*************************************************************************************************
1402 
1403 
1404 //*************************************************************************************************
1417 template< typename T // Type
1418  , typename D // Deletion policy
1419  , typename G > // Growth policy
1420 template< typename IteratorType >
1421 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType first, IteratorType last )
1422 {
1423  insert( pos, first, last, typename IteratorType::iterator_category() );
1424 }
1425 //*************************************************************************************************
1426 
1427 
1428 //*************************************************************************************************
1442 template< typename T // Type
1443  , typename D // Deletion policy
1444  , typename G > // Growth policy
1445 template< typename IteratorType >
1446 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType* first, IteratorType* last )
1447 {
1448  insert( pos, first, last, std::random_access_iterator_tag() );
1449 }
1451 //*************************************************************************************************
1452 
1453 
1454 //*************************************************************************************************
1465 template< typename T // Type
1466  , typename D // Deletion policy
1467  , typename G > // Growth policy
1469 {
1470  T** const base = const_cast<T**>( pos.base() );
1471  deleteElement( *base );
1472  std::copy( base+1, end_, base );
1473 
1474  --size_;
1475  --end_;
1476 
1477  return pos;
1478 }
1479 //*************************************************************************************************
1480 
1481 
1482 //*************************************************************************************************
1493 template< typename T // Type
1494  , typename D // Deletion policy
1495  , typename G > // Growth policy
1496 template< typename C > // Cast type
1497 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C>
1499 {
1500  T** const base = const_cast<T**>( pos.base() );
1501  deleteElement( *base );
1502  std::copy( base+1, end_, base );
1503 
1504  --size_;
1505  --end_;
1506 
1507  return CastIterator<C>( base, end_ );
1508 }
1509 //*************************************************************************************************
1510 
1511 
1512 //*************************************************************************************************
1522 template< typename T // Type
1523  , typename D // Deletion policy
1524  , typename G > // Growth policy
1526 {
1527  T** const base = const_cast<T**>( pos.base() );
1528  std::copy( base+1, end_, base );
1529 
1530  --size_;
1531  --end_;
1532 
1533  return pos;
1534 }
1535 //*************************************************************************************************
1536 
1537 
1538 //*************************************************************************************************
1548 template< typename T // Type
1549  , typename D // Deletion policy
1550  , typename G > // Growth policy
1551 template< typename C > // Cast type
1552 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C>
1554 {
1555  T** const base = const_cast<T**>( pos.base() );
1556  std::copy( base+1, end_, base );
1557 
1558  --size_;
1559  --end_;
1560 
1561  return CastIterator<C>( base, end_ );
1562 }
1563 //*************************************************************************************************
1564 
1565 
1566 //*************************************************************************************************
1571 template< typename T // Type
1572  , typename D // Deletion policy
1573  , typename G > // Growth policy
1575 {
1576  for( PointerType* it=begin_; it!=end_; ++it )
1577  deleteElement( *it );
1578 
1579  end_ = begin_;
1580  size_ = 0;
1581 }
1582 //*************************************************************************************************
1583 
1584 
1585 
1586 
1587 //=================================================================================================
1588 //
1589 // UTILITY FUNCTIONS
1590 //
1591 //=================================================================================================
1592 
1593 //*************************************************************************************************
1599 template< typename T // Type
1600  , typename D // Deletion policy
1601  , typename G > // Growth policy
1603 {
1604  if( newCapacity > capacity_ )
1605  {
1606  // Calculating the new capacity
1607  newCapacity = calcCapacity( newCapacity );
1608 
1609  // Allocating a new array
1610  PointerType* tmp = new PointerType[newCapacity];
1611 
1612  // Replacing the old array
1613  std::copy( begin_, end_, tmp );
1614  std::swap( tmp, begin_ );
1615  capacity_ = newCapacity;
1616  end_ = begin_ + size_;
1617  delete [] tmp;
1618  }
1619 }
1620 //*************************************************************************************************
1621 
1622 
1623 //*************************************************************************************************
1630 template< typename T // Type
1631  , typename D // Deletion policy
1632  , typename G > // Growth policy
1633 inline void PtrVector<T,D,G>::swap( PtrVector& pv ) noexcept
1634 {
1635  // By using the 'std::swap' function to swap all member variables,
1636  // the function can give the nothrow guarantee.
1637  std::swap( size_, pv.size_ );
1638  std::swap( capacity_, pv.capacity_ );
1639  std::swap( begin_, pv.begin_ );
1640  std::swap( end_, pv.end_ );
1641 }
1642 //*************************************************************************************************
1643 
1644 
1645 
1646 
1647 //=================================================================================================
1648 //
1649 // HELPER FUNCTIONS
1650 //
1651 //=================================================================================================
1652 
1653 //*************************************************************************************************
1659 template< typename T // Type
1660  , typename D // Deletion policy
1661  , typename G > // Growth policy
1662 inline size_t PtrVector<T,D,G>::calcCapacity( size_t minCapacity ) const
1663 {
1664  BLAZE_INTERNAL_ASSERT( minCapacity > capacity_, "Invalid new vector capacity" );
1665  const size_t newCapacity( GrowthPolicy()( capacity_, minCapacity ) );
1666  BLAZE_INTERNAL_ASSERT( newCapacity > capacity_, "Invalid new vector capacity" );
1667  return newCapacity;
1668 }
1669 //*************************************************************************************************
1670 
1671 
1672 //*************************************************************************************************
1678 template< typename T // Type
1679  , typename D // Deletion policy
1680  , typename G > // Growth policy
1682 {
1683  DeletionPolicy()( ptr );
1684 }
1685 //*************************************************************************************************
1686 
1687 
1688 
1689 
1690 //=================================================================================================
1691 //
1692 // INSERTION HELPER FUNCTIONS
1693 //
1694 //=================================================================================================
1695 
1696 //*************************************************************************************************
1704 template< typename T // Type
1705  , typename D // Deletion policy
1706  , typename G > // Growth policy
1707 void PtrVector<T,D,G>::insert( T**const pos, PointerType p )
1708 {
1709  if( size_ != capacity_ ) {
1710  std::copy_backward( pos, end_, end_+1 );
1711  *pos = p;
1712  ++end_;
1713  ++size_;
1714  }
1715  else if( size_ == maxSize() ) {
1716  BLAZE_THROW_LENGTH_ERROR( "Maximum pointer vector length exceeded!" );
1717  }
1718  else {
1719  SizeType newCapacity( calcCapacity( capacity_+1 ) );
1720  if( newCapacity > maxSize() || newCapacity < capacity_ ) newCapacity = maxSize();
1721 
1722  PointerType* newBegin = new PointerType[newCapacity];
1723  PointerType* newEnd = std::copy( begin_, pos, newBegin );
1724  *newEnd = p;
1725  ++newEnd;
1726  end_ = std::copy( pos, end_, newEnd );
1727 
1728  std::swap( newBegin, begin_ );
1729  delete [] newBegin;
1730  capacity_ = newCapacity;
1731  ++size_;
1732  }
1733 }
1734 //*************************************************************************************************
1735 
1736 
1737 //*************************************************************************************************
1750 template< typename T // Type
1751  , typename D // Deletion policy
1752  , typename G > // Growth policy
1753 template< typename IteratorType >
1754 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType first, IteratorType last,
1755  std::input_iterator_tag )
1756 {
1757  for( ; first!=last; ++first ) {
1758  pos = insert( pos, *first );
1759  ++pos;
1760  }
1761 }
1763 //*************************************************************************************************
1764 
1765 
1766 //*************************************************************************************************
1779 template< typename T // Type
1780  , typename D // Deletion policy
1781  , typename G > // Growth policy
1782 template< typename IteratorType >
1783 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType first, IteratorType last,
1784  std::random_access_iterator_tag )
1785 {
1786  T** const base = const_cast<T**>( pos.base() );
1787  const SizeType diff( last - first );
1788 
1789  if( size_+diff <= capacity_ && base == end_ ) {
1790  for( ; first!=last; ++first, ++end_ ) {
1791  *end_ = *first;
1792  }
1793  size_ += diff;
1794  }
1795  else {
1796  insert( base, first, last, diff );
1797  }
1798 }
1800 //*************************************************************************************************
1801 
1802 
1803 //*************************************************************************************************
1813 template< typename T // Type
1814  , typename D // Deletion policy
1815  , typename G > // Growth policy
1816 template< typename IteratorType >
1817 void PtrVector<T,D,G>::insert( T** pos, IteratorType first, IteratorType last, SizeType n )
1818 {
1819  const SizeType newSize( size_ + n );
1820 
1821  if( newSize <= capacity_ ) {
1822  std::copy_backward( pos, end_, end_+n );
1823  for( ; first!=last; ++first, ++pos ) {
1824  *pos = *first;
1825  }
1826  end_ += n;
1827  size_ = newSize;
1828  }
1829  else if( newSize > maxSize() || newSize < size_ ) {
1830  BLAZE_THROW_LENGTH_ERROR( "Maximum pointer vector length exceeded!" );
1831  }
1832  else {
1833  PointerType* newBegin = new PointerType[newSize];
1834  PointerType* newEnd = std::copy( begin_, pos, newBegin );
1835 
1836  for( ; first!=last; ++first, ++newEnd ) {
1837  *newEnd = *first;
1838  }
1839 
1840  end_ = std::copy( pos, end_, newEnd );
1841 
1842  std::swap( newBegin, begin_ );
1843  delete [] newBegin;
1844  capacity_ = newSize;
1845  size_ = newSize;
1846  }
1847 }
1848 //*************************************************************************************************
1849 
1850 
1851 
1852 
1853 //=================================================================================================
1854 //
1855 // GLOBAL OPERATORS
1856 //
1857 //=================================================================================================
1858 
1859 //*************************************************************************************************
1862 template< typename T, typename D, typename G >
1863 inline bool operator==( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs );
1864 
1865 template< typename T, typename D, typename G >
1866 inline bool operator!=( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs );
1867 
1868 template< typename T, typename D, typename G >
1869 inline void swap( PtrVector<T,D,G>& a, PtrVector<T,D,G>& b ) noexcept;
1871 //*************************************************************************************************
1872 
1873 
1874 //*************************************************************************************************
1881 template< typename T // Type
1882  , typename D // Deletion policy
1883  , typename G > // Growth policy
1884 inline bool operator==( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs )
1885 {
1886  return lhs.size() == rhs.size() && std::equal( lhs.begin(), lhs.end(), rhs.begin() );
1887 }
1888 //*************************************************************************************************
1889 
1890 
1891 //*************************************************************************************************
1898 template< typename T // Type
1899  , typename D // Deletion policy
1900  , typename G > // Growth policy
1901 inline bool operator!=( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs )
1902 {
1903  return lhs.size() != rhs.size() || !std::equal( lhs.begin(), lhs.end(), rhs.begin() );
1904 }
1905 //*************************************************************************************************
1906 
1907 
1908 //*************************************************************************************************
1916 template< typename T // Type
1917  , typename D // Deletion policy
1918  , typename G > // Growth policy
1919 inline void swap( PtrVector<T,D,G>& a, PtrVector<T,D,G>& b ) noexcept
1920 {
1921  a.swap( b );
1922 }
1923 //*************************************************************************************************
1924 
1925 
1926 
1927 
1928 
1929 
1930 
1931 
1932 //=================================================================================================
1933 //
1934 // NESTED CLASS PTRVECTOR::CASTITERATOR
1935 //
1936 //=================================================================================================
1937 
1938 //*************************************************************************************************
1961 template< typename T // Type
1962  , typename D // Deletion policy
1963  , typename G > // Growth policy
1964 template< typename C > // Cast type
1965 class PtrVector<T,D,G>::CastIterator
1966 {
1967  public:
1968  //**Type definitions****************************************************************************
1969  // Blaze naming convention
1970  typedef std::forward_iterator_tag IteratorCategory;
1971  typedef C* ValueType;
1972  typedef C* PointerType;
1973  typedef C* const& ReferenceType;
1975  typedef T* const* IteratorType;
1976 
1977  // STL iterator requirements
1978  typedef IteratorCategory iterator_category;
1979  typedef ValueType value_type;
1980  typedef PointerType pointer;
1981  typedef ReferenceType reference;
1982  typedef DifferenceType difference_type;
1983  //**********************************************************************************************
1984 
1985  //**Constructors********************************************************************************
1988  inline CastIterator();
1989  inline CastIterator( IteratorType begin, IteratorType end );
1990 
1991  template< typename Other >
1992  inline CastIterator( const CastIterator<Other>& it );
1993 
1994  // No explicitly declared copy constructor.
1996  //**********************************************************************************************
1997 
1998  //**Destructor**********************************************************************************
1999  // No explicitly declared destructor.
2000  //**********************************************************************************************
2001 
2002  //**Copy assignment operator********************************************************************
2003  // No explicitly declared copy assignment operator.
2004  //**********************************************************************************************
2005 
2006  //**Operators***********************************************************************************
2009  inline CastIterator& operator++();
2010  inline CastIterator operator++( int );
2012  //**********************************************************************************************
2013 
2014  //**Access operators****************************************************************************
2017  inline PointerType operator*() const;
2018  inline PointerType operator->() const;
2020  //**********************************************************************************************
2021 
2022  //**Utility functions***************************************************************************
2025  inline const IteratorType& base() const;
2026  inline const IteratorType& stop() const;
2028  //**********************************************************************************************
2029 
2030  private:
2031  //**Member variables****************************************************************************
2034  IteratorType cur_;
2035  IteratorType end_;
2036 
2037  //**********************************************************************************************
2038 };
2039 //*************************************************************************************************
2040 
2041 
2042 
2043 
2044 //=================================================================================================
2045 //
2046 // CONSTRUCTOR
2047 //
2048 //=================================================================================================
2049 
2050 //*************************************************************************************************
2053 template< typename T // Type
2054  , typename D // Deletion policy
2055  , typename G > // Growth policy
2056 template< typename C > // Cast type
2058  : cur_( nullptr ) // Pointer to the current memory location
2059  , end_( nullptr ) // Pointer to the element one past the last element in the element range
2060 {
2062 }
2063 //*************************************************************************************************
2064 
2065 
2066 //*************************************************************************************************
2072 template< typename T // Type
2073  , typename D // Deletion policy
2074  , typename G > // Growth policy
2075 template< typename C > // Cast type
2077  : cur_(begin) // Pointer to the current memory location
2078  , end_(end) // Pointer to the element one past the last element in the element range
2079 {
2080  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2081  // contained in the range [cur_,end). An equivalent code might look like this:
2082  //
2083  // while( cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) ++cur_;
2084  //
2085  // However, the specialization of polymorphicFind() for special type combinations is much
2086  // more efficient (and way easier!) than the specialization of this function!
2087  cur_ = polymorphicFind<C>( cur_, end_ );
2088 }
2089 //*************************************************************************************************
2090 
2091 
2092 //*************************************************************************************************
2097 template< typename T // Type
2098  , typename D // Deletion policy
2099  , typename G > // Growth policy
2100 template< typename C > // Cast type
2101 template< typename Other > // The foreign cast iterator type
2103  : cur_( it.base() ) // Pointer to the current memory location
2104  , end_( it.stop() ) // Pointer to the element one past the last element in the element range
2105 {
2108 }
2109 //*************************************************************************************************
2110 
2111 
2112 
2113 
2114 //=================================================================================================
2115 //
2116 // OPERATORS
2117 //
2118 //=================================================================================================
2119 
2120 //*************************************************************************************************
2125 template< typename T // Type
2126  , typename D // Deletion policy
2127  , typename G > // Growth policy
2128 template< typename C > // Cast type
2131 {
2132  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2133  // contained in the range [cur_+1,end). An equivalent code might look like this:
2134  //
2135  // while( ++cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) {}
2136  //
2137  // However, the specialization of polymorphicFind() for special type combinations is much
2138  // more efficient (and way easier!) than the specialization of this function!
2139  cur_ = polymorphicFind<C>( ++cur_, end_ );
2140 
2141  return *this;
2142 }
2143 //*************************************************************************************************
2144 
2145 
2146 //*************************************************************************************************
2151 template< typename T // Type
2152  , typename D // Deletion policy
2153  , typename G > // Growth policy
2154 template< typename C > // Cast type
2157 {
2158  CastIterator tmp( *this );
2159 
2160  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2161  // contained in the range [cur_+1,end). An equivalent code might look like this:
2162  //
2163  // while( ++cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) {}
2164  //
2165  // However, the specialization of polymorphicFind() for special type combinations is much
2166  // more efficient (and way easier!) than the specialization of this function!
2167  cur_ = polymorphicFind<C>( ++cur_, end_ );
2168 
2169  return tmp;
2170 }
2171 //*************************************************************************************************
2172 
2173 
2174 
2175 
2176 //=================================================================================================
2177 //
2178 // ACCESS OPERATORS
2179 //
2180 //=================================================================================================
2181 
2182 //*************************************************************************************************
2187 template< typename T // Type
2188  , typename D // Deletion policy
2189  , typename G > // Growth policy
2190 template< typename C > // Cast type
2193 {
2194  return static_cast<C*>( *cur_ );
2195 }
2196 //*************************************************************************************************
2197 
2198 
2199 //*************************************************************************************************
2204 template< typename T // Type
2205  , typename D // Deletion policy
2206  , typename G > // Growth policy
2207 template< typename C > // Cast type
2210 {
2211  return static_cast<C*>( *cur_ );
2212 }
2213 //*************************************************************************************************
2214 
2215 
2216 
2217 
2218 //=================================================================================================
2219 //
2220 // UTILITY FUNCTIONS
2221 //
2222 //=================================================================================================
2223 
2224 //*************************************************************************************************
2229 template< typename T // Type
2230  , typename D // Deletion policy
2231  , typename G > // Growth policy
2232 template< typename C > // Cast type
2235 {
2236  return cur_;
2237 }
2238 //*************************************************************************************************
2239 
2240 
2241 //*************************************************************************************************
2246 template< typename T // Type
2247  , typename D // Deletion policy
2248  , typename G > // Growth policy
2249 template< typename C > // Cast type
2252 {
2253  return end_;
2254 }
2255 //*************************************************************************************************
2256 
2257 
2258 
2259 
2260 
2261 
2262 
2263 
2264 //=================================================================================================
2265 //
2266 // NESTED CLASS PTRVECTOR::CONSTCASTITERATOR
2267 //
2268 //=================================================================================================
2269 
2270 //*************************************************************************************************
2294 template< typename T // Type
2295  , typename D // Deletion policy
2296  , typename G > // Growth policy
2297 template< typename C > // Cast type
2298 class PtrVector<T,D,G>::ConstCastIterator
2299 {
2300  public:
2301  //**Type definitions****************************************************************************
2302  // Blaze naming convention
2303  typedef std::forward_iterator_tag IteratorCategory;
2304  typedef const C* ValueType;
2305  typedef const C* PointerType;
2306  typedef const C* const& ReferenceType;
2308  typedef const T* const* IteratorType;
2309 
2310  // STL iterator requirements
2311  typedef IteratorCategory iterator_category;
2312  typedef ValueType value_type;
2313  typedef PointerType pointer;
2314  typedef ReferenceType reference;
2315  typedef DifferenceType difference_type;
2316  //**********************************************************************************************
2317 
2318  //**Constructors********************************************************************************
2321  inline ConstCastIterator();
2322  inline ConstCastIterator( IteratorType begin, IteratorType end );
2323 
2324  template< typename Other >
2325  inline ConstCastIterator( const ConstCastIterator<Other>& it );
2326 
2327  template< typename Other >
2329 
2330  // No explicitly declared copy constructor.
2332  //**********************************************************************************************
2333 
2334  //**Destructor**********************************************************************************
2335  // No explicitly declared destructor.
2336  //**********************************************************************************************
2337 
2338  //**Copy assignment operator********************************************************************
2339  // No explicitly declared copy assignment operator.
2340  //**********************************************************************************************
2341 
2342  //**Operators***********************************************************************************
2345  inline ConstCastIterator& operator++();
2346  inline ConstCastIterator operator++( int );
2348  //**********************************************************************************************
2349 
2350  //**Access operators****************************************************************************
2353  inline PointerType operator*() const;
2354  inline PointerType operator->() const;
2356  //**********************************************************************************************
2357 
2358  //**Utility functions***************************************************************************
2361  inline const IteratorType& base() const;
2362  inline const IteratorType& stop() const;
2364  //**********************************************************************************************
2365 
2366  private:
2367  //**Member variables****************************************************************************
2370  IteratorType cur_;
2371  IteratorType end_;
2372 
2373  //**********************************************************************************************
2374 };
2375 //*************************************************************************************************
2376 
2377 
2378 
2379 
2380 //=================================================================================================
2381 //
2382 // CONSTRUCTOR
2383 //
2384 //=================================================================================================
2385 
2386 //*************************************************************************************************
2389 template< typename T // Type
2390  , typename D // Deletion policy
2391  , typename G > // Growth policy
2392 template< typename C > // Cast type
2394  : cur_( nullptr ) // Pointer to the current memory location
2395  , end_( nullptr ) // Pointer to the element one past the last element in the element range
2396 {
2398 }
2399 //*************************************************************************************************
2400 
2401 
2402 //*************************************************************************************************
2408 template< typename T // Type
2409  , typename D // Deletion policy
2410  , typename G > // Growth policy
2411 template< typename C > // Cast type
2413  : cur_(begin) // Pointer to the current memory location
2414  , end_(end) // Pointer to the element one past the last element in the element range
2415 {
2416  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2417  // contained in the range [cur_,end). An equivalent code might look like this:
2418  //
2419  // while( cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) ++cur_;
2420  //
2421  // However, the specialization of polymorphicFind() for special type combinations is much
2422  // more efficient (and way easier!) than the specialization of this function!
2423  cur_ = polymorphicFind<C>( cur_, end_ );
2424 }
2425 //*************************************************************************************************
2426 
2427 
2428 //*************************************************************************************************
2433 template< typename T // Type
2434  , typename D // Deletion policy
2435  , typename G > // Growth policy
2436 template< typename C > // Cast type
2437 template< typename Other > // The foreign constant cast iterator type
2439  : cur_( it.base() ) // Pointer to the current memory location
2440  , end_( it.stop() ) // Pointer to the element one past the last element in the element range
2441 {
2444 }
2445 //*************************************************************************************************
2446 
2447 
2448 //*************************************************************************************************
2453 template< typename T // Type
2454  , typename D // Deletion policy
2455  , typename G > // Growth policy
2456 template< typename C > // Cast type
2457 template< typename Other > // The foreign cast iterator type
2459  : cur_( it.base() ) // Pointer to the current memory location
2460  , end_( it.stop() ) // Pointer to the element one past the last element in the element range
2461 {
2464 }
2465 //*************************************************************************************************
2466 
2467 
2468 
2469 
2470 //=================================================================================================
2471 //
2472 // OPERATORS
2473 //
2474 //=================================================================================================
2475 
2476 //*************************************************************************************************
2481 template< typename T // Type
2482  , typename D // Deletion policy
2483  , typename G > // Growth policy
2484 template< typename C > // Cast type
2487 {
2488  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2489  // contained in the range [cur_+1,end). An equivalent code might look like this:
2490  //
2491  // while( ++cur_ != end_ && !dynamic_cast<const C*>( *cur_ ) ) {}
2492  //
2493  // However, the specialization of polymorphicFind() for special type combinations is much
2494  // more efficient (and way easier!) than the specialization of this function!
2495  cur_ = polymorphicFind<const C>( ++cur_, end_ );
2496 
2497  return *this;
2498 }
2499 //*************************************************************************************************
2500 
2501 
2502 //*************************************************************************************************
2507 template< typename T // Type
2508  , typename D // Deletion policy
2509  , typename G > // Growth policy
2510 template< typename C > // Cast type
2513 {
2514  ConstCastIterator tmp( *this );
2515 
2516  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2517  // contained in the range [cur_+1,end). An equivalent code might look like this:
2518  //
2519  // while( ++cur_ != end_ && !dynamic_cast<const C*>( *cur_ ) ) {}
2520  //
2521  // However, the specialization of polymorphicFind() for special type combinations is much
2522  // more efficient (and way easier!) than the specialization of this function!
2523  cur_ = polymorphicFind<const C>( ++cur_, end_ );
2524 
2525  return tmp;
2526 }
2527 //*************************************************************************************************
2528 
2529 
2530 
2531 
2532 //=================================================================================================
2533 //
2534 // ACCESS OPERATORS
2535 //
2536 //=================================================================================================
2537 
2538 //*************************************************************************************************
2543 template< typename T // Type
2544  , typename D // Deletion policy
2545  , typename G > // Growth policy
2546 template< typename C > // Cast type
2549 {
2550  return static_cast<const C*>( *cur_ );
2551 }
2552 //*************************************************************************************************
2553 
2554 
2555 //*************************************************************************************************
2560 template< typename T // Type
2561  , typename D // Deletion policy
2562  , typename G > // Growth policy
2563 template< typename C > // Cast type
2566 {
2567  return static_cast<const C*>( *cur_ );
2568 }
2569 //*************************************************************************************************
2570 
2571 
2572 
2573 
2574 //=================================================================================================
2575 //
2576 // UTILITY FUNCTIONS
2577 //
2578 //=================================================================================================
2579 
2580 //*************************************************************************************************
2585 template< typename T // Type
2586  , typename D // Deletion policy
2587  , typename G > // Growth policy
2588 template< typename C > // Cast type
2591 {
2592  return cur_;
2593 }
2594 //*************************************************************************************************
2595 
2596 
2597 //*************************************************************************************************
2602 template< typename T // Type
2603  , typename D // Deletion policy
2604  , typename G > // Growth policy
2605 template< typename C > // Cast type
2608 {
2609  return end_;
2610 }
2611 //*************************************************************************************************
2612 
2613 } // namespace blaze
2614 
2615 #endif
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