All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <stdexcept>
45 #include <blaze/util/Algorithm.h>
46 #include <blaze/util/Assert.h>
49 #include <blaze/util/Null.h>
52 #include <blaze/util/PtrIterator.h>
53 #include <blaze/util/Template.h>
54 #include <blaze/util/Types.h>
55 
56 
57 namespace blaze {
58 
59 //=================================================================================================
60 //
61 // CLASS DEFINITION
62 //
63 //=================================================================================================
64 
65 //*************************************************************************************************
279 template< typename T // Type
280  , typename D = PtrDelete // Deletion policy
281  , typename G = OptimalGrowth > // Growth policy
283 {
284  private:
285  //**Friend declarations*************************************************************************
287  template< typename T2, typename D2, typename G2 > friend class PtrVector;
289  //**********************************************************************************************
290 
291  public:
292  //**Type definitions****************************************************************************
293  // Blaze naming convention
294  typedef T* ValueType;
295  typedef T* PointerType;
296  typedef const T* ConstPointerType;
297  typedef T*& ReferenceType;
298  typedef T*const& ConstReferenceType;
299  typedef size_t SizeType;
302  typedef D DeletionPolicy;
303  typedef G GrowthPolicy;
304 
305  // STL iterator requirements
311  typedef SizeType size_type;
312  //**********************************************************************************************
313 
314  //**Forward declarations for nested classes*****************************************************
315  template< typename C > class CastIterator;
316  template< typename C > class ConstCastIterator;
317  //**********************************************************************************************
318 
319  //**Constructors********************************************************************************
322  explicit inline PtrVector( SizeType initCapacity = 0 );
323  inline PtrVector( const PtrVector& pv );
324 
325  template< typename T2, typename D2, typename G2 >
326  inline PtrVector( const PtrVector<T2,D2,G2>& pv );
328  //**********************************************************************************************
329 
330  //**Destructor**********************************************************************************
333  inline ~PtrVector();
335  //**********************************************************************************************
336 
337  //**Assignment operators************************************************************************
340  PtrVector& operator=( const PtrVector& pv );
341 
342  template< typename T2, typename D2, typename G2 >
345  //**********************************************************************************************
346 
347  //**Get functions*******************************************************************************
350  inline SizeType maxSize() const;
351  inline SizeType size() const;
352  template< typename C > inline SizeType size() const;
353  inline SizeType capacity() const;
354  inline bool isEmpty() const;
356  //**********************************************************************************************
357 
358  //**Access functions****************************************************************************
361  inline ReferenceType operator[]( SizeType index );
362  inline ConstReferenceType operator[]( SizeType index ) const;
363  inline ReferenceType front();
364  inline ConstReferenceType front() const;
365  inline ReferenceType back();
366  inline ConstReferenceType back() const;
368  //**********************************************************************************************
369 
370  //**Iterator functions**************************************************************************
373  inline Iterator begin();
374  inline ConstIterator begin() const;
375  template< typename C > inline CastIterator<C> begin();
376  template< typename C > inline ConstCastIterator<C> begin() const;
377 
378  inline Iterator end();
379  inline ConstIterator end() const;
380  template< typename C > inline CastIterator<C> end();
381  template< typename C > inline ConstCastIterator<C> end() const;
383  //**********************************************************************************************
384 
385  //**Element functions***************************************************************************
388  inline void pushBack ( PointerType p );
389  inline void popBack ();
390  inline void releaseBack();
391 
392  template< typename IteratorType >
393  inline void assign( IteratorType first, IteratorType last );
394 
395  inline Iterator insert( Iterator pos, PointerType p );
396 
397  template< typename IteratorType >
398  inline void insert( Iterator pos, IteratorType first, IteratorType last );
399 
401  template< typename IteratorType >
402  inline void insert( Iterator pos, IteratorType* first, IteratorType* last );
405  inline Iterator erase ( Iterator pos );
406  template< typename C > inline CastIterator<C> erase ( CastIterator<C> pos );
407  inline Iterator release( Iterator pos );
408  template< typename C > inline CastIterator<C> release( CastIterator<C> pos );
409  inline void clear ();
411  //**********************************************************************************************
412 
413  //**Utility functions***************************************************************************
416  void reserve( SizeType newCapacity );
417  inline void swap( PtrVector& pv ) /* throw() */;
419  //**********************************************************************************************
420 
421  private:
422  //**Helper functions****************************************************************************
425  inline size_t calcCapacity ( size_t minCapacity ) const;
426  inline void deleteElement( PointerType ptr ) const;
428  //**********************************************************************************************
429 
430  //**Insertion helper functions******************************************************************
433  void insert( T**const pos, PointerType p );
434 
436  template< typename IteratorType >
437  inline void insert( Iterator pos, IteratorType first, IteratorType last, std::input_iterator_tag );
438 
439  template< typename IteratorType >
440  inline void insert( Iterator pos, IteratorType first, IteratorType last, std::random_access_iterator_tag );
443  template< typename IteratorType >
444  void insert( T** pos, IteratorType first, IteratorType last, SizeType n );
446  //**********************************************************************************************
447 
448  //**Member variables****************************************************************************
455 
456  //**********************************************************************************************
457 
458  public:
459  //**CastIterator/ConstCastIterator comparison operators*****************************************
460  // The following comparison operators cannot be defined as namespace or member functions
461  // but have to be injected into the surrounding scope via the Barton-Nackman trick since
462  // the template arguments of nested templates cannot be deduced (C++ standard 14.8.2.4/4).
465 
466  //**********************************************************************************************
473  template< typename L, typename R >
474  friend inline bool operator==( const CastIterator<L>& lhs, const CastIterator<R>& rhs )
475  {
476  return lhs.base() == rhs.base();
477  }
478  //**********************************************************************************************
479 
480  //**********************************************************************************************
487  template< typename L, typename R >
488  friend inline bool operator==( const CastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
489  {
490  return lhs.base() == rhs.base();
491  }
492  //**********************************************************************************************
493 
494  //**********************************************************************************************
501  template< typename L, typename R >
502  friend inline bool operator==( const ConstCastIterator<L>& lhs, const CastIterator<R>& rhs )
503  {
504  return lhs.base() == rhs.base();
505  }
506  //**********************************************************************************************
507 
508  //**********************************************************************************************
515  template< typename L, typename R >
516  friend inline bool operator==( const ConstCastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
517  {
518  return lhs.base() == rhs.base();
519  }
520  //**********************************************************************************************
521 
522  //**********************************************************************************************
529  template< typename L, typename R >
530  friend inline bool operator!=( const CastIterator<L>& lhs, const CastIterator<R>& rhs )
531  {
532  return lhs.base() != rhs.base();
533  }
534  //**********************************************************************************************
535 
536  //**********************************************************************************************
543  template< typename L, typename R >
544  friend inline bool operator!=( const CastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
545  {
546  return lhs.base() != rhs.base();
547  }
548  //**********************************************************************************************
549 
550  //**********************************************************************************************
557  template< typename L, typename R >
558  friend inline bool operator!=( const ConstCastIterator<L>& lhs, const CastIterator<R>& rhs )
559  {
560  return lhs.base() != rhs.base();
561  }
562  //**********************************************************************************************
563 
564  //**********************************************************************************************
571  template< typename L, typename R >
572  friend inline bool operator!=( const ConstCastIterator<L>& lhs, const ConstCastIterator<R>& rhs )
573  {
574  return lhs.base() != rhs.base();
575  }
576  //**********************************************************************************************
577 
579  //**********************************************************************************************
580 };
581 //*************************************************************************************************
582 
583 
584 
585 
586 //=================================================================================================
587 //
588 // CONSTRUCTORS
589 //
590 //=================================================================================================
591 
592 //*************************************************************************************************
599 template< typename T // Type
600  , typename D // Deletion policy
601  , typename G > // Growth policy
602 inline PtrVector<T,D,G>::PtrVector( SizeType initCapacity )
603  : size_( 0 ) // Current size of the pointer vector
604  , capacity_( initCapacity ) // Capacity of the pointer vector
605  , begin_( new PointerType[initCapacity] ) // Pointer to the first element
606  , end_( begin_ ) // Pointer to the last element
607 {}
608 //*************************************************************************************************
609 
610 
611 //*************************************************************************************************
616 template< typename T // Type
617  , typename D // Deletion policy
618  , typename G > // Growth policy
620  : size_( pv.size_ ) // Current size of the pointer vector
621  , capacity_( pv.size_ ) // Capacity of the pointer vector
622  , begin_( new PointerType[capacity_] ) // Pointer to the first element
623  , end_( begin_+size_ ) // Pointer to the last element
624 {
625  for( SizeType i=0; i<size_; ++i )
626  begin_[i] = pv.begin_[i];
627 }
628 //*************************************************************************************************
629 
630 
631 //*************************************************************************************************
636 template< typename T // Type of the pointer vector
637  , typename D // Deletion policy of the pointer vector
638  , typename G > // Growth policy of the pointer vector
639 template< typename T2 // Type of the foreign pointer vector
640  , typename D2 // Deletion policy of the foreign pointer vector
641  , typename G2 > // Growth policy of the foreign pointer vector
643  : size_( pv.size_ ) // Current size of the pointer vector
644  , capacity_( pv.size_ ) // Capacity of the pointer vector
645  , begin_( new PointerType[capacity_] ) // Pointer to the first element
646  , end_( begin_+size_ ) // Pointer to the last element
647 {
648  for( SizeType i=0; i<size_; ++i )
649  begin_[i] = pv.begin_[i];
650 }
651 //*************************************************************************************************
652 
653 
654 
655 
656 //=================================================================================================
657 //
658 // DESTRUCTOR
659 //
660 //=================================================================================================
661 
662 //*************************************************************************************************
668 template< typename T // Type
669  , typename D // Deletion policy
670  , typename G > // Growth policy
672 {
673  for( PointerType* it=begin_; it!=end_; ++it )
674  deleteElement( *it );
675  delete [] begin_;
676 }
677 //*************************************************************************************************
678 
679 
680 
681 
682 //=================================================================================================
683 //
684 // ASSIGNMENT OPERATORS
685 //
686 //=================================================================================================
687 
688 //*************************************************************************************************
694 template< typename T // Type
695  , typename D // Deletion policy
696  , typename G > // Growth policy
698 {
699  if( &pv == this ) return *this;
700 
701  if( pv.size_ > capacity_ ) {
702  PointerType* newBegin( new PointerType[pv.size_] );
703  end_ = std::copy( pv.begin_, pv.end_, newBegin );
704  std::swap( begin_, newBegin );
705  delete [] newBegin;
706 
707  size_ = pv.size_;
708  capacity_ = pv.size_;
709  }
710  else {
711  end_ = std::copy( pv.begin_, pv.end_, begin_ );
712  size_ = pv.size_;
713  }
714 
715  return *this;
716 }
717 //*************************************************************************************************
718 
719 
720 //*************************************************************************************************
726 template< typename T // Type of the pointer vector
727  , typename D // Deletion policy of the pointer vector
728  , typename G > // Growth policy of the pointer vector
729 template< typename T2 // Type of the foreign pointer vector
730  , typename D2 // Deletion policy of the foreign pointer vector
731  , typename G2 > // Growth policy of the foreign pointer vector
733 {
734  if( pv.size_ > capacity_ ) {
735  PointerType* newBegin( new PointerType[pv.size_] );
736  end_ = std::copy( pv.begin_, pv.end_, newBegin );
737  std::swap( begin_, newBegin );
738  delete [] newBegin;
739 
740  size_ = pv.size_;
741  capacity_ = pv.size_;
742  }
743  else {
744  end_ = std::copy( pv.begin_, pv.end_, begin_ );
745  size_ = pv.size_;
746  }
747 
748  return *this;
749 }
750 //*************************************************************************************************
751 
752 
753 
754 
755 //=================================================================================================
756 //
757 // GET FUNCTIONS
758 //
759 //=================================================================================================
760 
761 //*************************************************************************************************
766 template< typename T // Type
767  , typename D // Deletion policy
768  , typename G > // Growth policy
770 {
771  return SizeType(-1) / sizeof(PointerType);
772 }
773 //*************************************************************************************************
774 
775 
776 //*************************************************************************************************
781 template< typename T // Type
782  , typename D // Deletion policy
783  , typename G > // Growth policy
785 {
786  return size_;
787 }
788 //*************************************************************************************************
789 
790 
791 //*************************************************************************************************
819 template< typename T // Type
820  , typename D // Deletion policy
821  , typename G > // Growth policy
822 template< typename C > // Cast type
824 {
825  // The polymorphicCount() function returns the number of objects with dynamic type 'C'
826  // contained in the range [begin,end). An equivalent code might look like this:
827  //
828  // SizeType count( 0 );
829  // for( PointerType* it=begin_; it!=end_; ++it )
830  // if( dynamic_cast<C*>( *it ) ) ++count;
831  // return count;
832  //
833  // However, the specialization of polymorphicCount() for special type combinations is
834  // much more efficient (and easier) than the specialization of this function!
835  return polymorphicCount<C>( begin_, end_ );
836 }
837 //*************************************************************************************************
838 
839 
840 //*************************************************************************************************
845 template< typename T // Type
846  , typename D // Deletion policy
847  , typename G > // Growth policy
849 {
850  return capacity_;
851 }
852 //*************************************************************************************************
853 
854 
855 //*************************************************************************************************
860 template< typename T // Type
861  , typename D // Deletion policy
862  , typename G > // Growth policy
863 inline bool PtrVector<T,D,G>::isEmpty() const
864 {
865  return size_ == 0;
866 }
867 //*************************************************************************************************
868 
869 
870 
871 
872 //=================================================================================================
873 //
874 // ACCESS FUNCTIONS
875 //
876 //=================================================================================================
877 
878 //*************************************************************************************************
886 template< typename T // Type
887  , typename D // Deletion policy
888  , typename G > // Growth policy
890 {
891  return *(begin_+index);
892 }
893 //*************************************************************************************************
894 
895 
896 //*************************************************************************************************
904 template< typename T // Type
905  , typename D // Deletion policy
906  , typename G > // Growth policy
908 {
909  return *(begin_+index);
910 }
911 //*************************************************************************************************
912 
913 
914 //*************************************************************************************************
921 template< typename T // Type
922  , typename D // Deletion policy
923  , typename G > // Growth policy
925 {
926  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the front element" );
927  return *begin_;
928 }
929 //*************************************************************************************************
930 
931 
932 //*************************************************************************************************
939 template< typename T // Type
940  , typename D // Deletion policy
941  , typename G > // Growth policy
943 {
944  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the front element" );
945  return *begin_;
946 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
957 template< typename T // Type
958  , typename D // Deletion policy
959  , typename G > // Growth policy
961 {
962  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the back element" );
963  return *(end_-1);
964 }
965 //*************************************************************************************************
966 
967 
968 //*************************************************************************************************
975 template< typename T // Type
976  , typename D // Deletion policy
977  , typename G > // Growth policy
979 {
980  BLAZE_USER_ASSERT( size_ > 0, "Pointer vector is empty, invalid access to the back element" );
981  return *(end_-1);
982 }
983 //*************************************************************************************************
984 
985 
986 
987 
988 //=================================================================================================
989 //
990 // ITERATOR FUNCTIONS
991 //
992 //=================================================================================================
993 
994 //*************************************************************************************************
999 template< typename T // Type
1000  , typename D // Deletion policy
1001  , typename G > // Growth policy
1003 {
1004  return Iterator( begin_ );
1005 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1014 template< typename T // Type
1015  , typename D // Deletion policy
1016  , typename G > // Growth policy
1018 {
1019  return ConstIterator( begin_ );
1020 }
1021 //*************************************************************************************************
1022 
1023 
1024 //*************************************************************************************************
1069 template< typename T // Type
1070  , typename D // Deletion policy
1071  , typename G > // Growth policy
1072 template< typename C > // Cast type
1073 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C> PtrVector<T,D,G>::begin()
1074 {
1075  return CastIterator<C>( begin_, end_ );
1076 }
1077 //*************************************************************************************************
1078 
1079 
1080 //*************************************************************************************************
1125 template< typename T // Type
1126  , typename D // Deletion policy
1127  , typename G > // Growth policy
1128 template< typename C > // Cast type
1129 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE ConstCastIterator<C> PtrVector<T,D,G>::begin() const
1130 {
1131  return ConstCastIterator<C>( begin_, end_ );
1132 }
1133 //*************************************************************************************************
1134 
1135 
1136 //*************************************************************************************************
1141 template< typename T // Type
1142  , typename D // Deletion policy
1143  , typename G > // Growth policy
1145 {
1146  return Iterator( end_ );
1147 }
1148 //*************************************************************************************************
1149 
1150 
1151 //*************************************************************************************************
1156 template< typename T // Type
1157  , typename D // Deletion policy
1158  , typename G > // Growth policy
1160 {
1161  return ConstIterator( end_ );
1162 }
1163 //*************************************************************************************************
1164 
1165 
1166 //*************************************************************************************************
1208 template< typename T // Type
1209  , typename D // Deletion policy
1210  , typename G > // Growth policy
1211 template< typename C > // Cast type
1212 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C> PtrVector<T,D,G>::end()
1213 {
1214  return CastIterator<C>( end_, end_ );
1215 }
1216 //*************************************************************************************************
1217 
1218 
1219 //*************************************************************************************************
1261 template< typename T // Type
1262  , typename D // Deletion policy
1263  , typename G > // Growth policy
1264 template< typename C > // Cast type
1265 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE ConstCastIterator<C> PtrVector<T,D,G>::end() const
1266 {
1267  return ConstCastIterator<C>( end_, end_ );
1268 }
1269 //*************************************************************************************************
1270 
1271 
1272 
1273 
1274 //=================================================================================================
1275 //
1276 // ELEMENT FUNCTIONS
1277 //
1278 //=================================================================================================
1279 
1280 //*************************************************************************************************
1289 template< typename T // Type
1290  , typename D // Deletion policy
1291  , typename G > // Growth policy
1293 {
1294  if( size_ != capacity_ ) {
1295  *end_ = p;
1296  ++end_;
1297  ++size_;
1298  }
1299  else {
1300  insert( end_, p );
1301  }
1302 }
1303 //*************************************************************************************************
1304 
1305 
1306 //*************************************************************************************************
1316 template< typename T // Type
1317  , typename D // Deletion policy
1318  , typename G > // Growth policy
1320 {
1321  deleteElement( *--end_ );
1322  --size_;
1323 }
1324 //*************************************************************************************************
1325 
1326 
1327 //*************************************************************************************************
1337 template< typename T // Type
1338  , typename D // Deletion policy
1339  , typename G > // Growth policy
1341 {
1342  --end_;
1343  --size_;
1344 }
1345 //*************************************************************************************************
1346 
1347 
1348 //*************************************************************************************************
1360 template< typename T // Type
1361  , typename D // Deletion policy
1362  , typename G > // Growth policy
1363 template< typename IteratorType >
1364 inline void PtrVector<T,D,G>::assign( IteratorType first, IteratorType last )
1365 {
1366  clear();
1367  insert( end(), first, last );
1368 }
1369 //*************************************************************************************************
1370 
1371 
1372 //*************************************************************************************************
1383 template< typename T // Type
1384  , typename D // Deletion policy
1385  , typename G > // Growth policy
1387 {
1388  T** const base = const_cast<T**>( pos.base() );
1389  const SizeType diff( base - begin_ );
1390 
1391  if( size_ != capacity_ && base == end_ ) {
1392  *end_ = p;
1393  ++end_;
1394  ++size_;
1395  }
1396  else {
1397  insert( base, p );
1398  }
1399 
1400  return Iterator( begin_+diff );
1401 }
1402 //*************************************************************************************************
1403 
1404 
1405 //*************************************************************************************************
1418 template< typename T // Type
1419  , typename D // Deletion policy
1420  , typename G > // Growth policy
1421 template< typename IteratorType >
1422 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType first, IteratorType last )
1423 {
1424  insert( pos, first, last, typename IteratorType::iterator_category() );
1425 }
1426 //*************************************************************************************************
1427 
1428 
1429 //*************************************************************************************************
1443 template< typename T // Type
1444  , typename D // Deletion policy
1445  , typename G > // Growth policy
1446 template< typename IteratorType >
1447 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType* first, IteratorType* last )
1448 {
1449  insert( pos, first, last, std::random_access_iterator_tag() );
1450 }
1452 //*************************************************************************************************
1453 
1454 
1455 //*************************************************************************************************
1466 template< typename T // Type
1467  , typename D // Deletion policy
1468  , typename G > // Growth policy
1470 {
1471  T** const base = const_cast<T**>( pos.base() );
1472  deleteElement( *base );
1473  std::copy( base+1, end_, base );
1474 
1475  --size_;
1476  --end_;
1477 
1478  return pos;
1479 }
1480 //*************************************************************************************************
1481 
1482 
1483 //*************************************************************************************************
1494 template< typename T // Type
1495  , typename D // Deletion policy
1496  , typename G > // Growth policy
1497 template< typename C > // Cast type
1498 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C>
1500 {
1501  T** const base = const_cast<T**>( pos.base() );
1502  deleteElement( *base );
1503  std::copy( base+1, end_, base );
1504 
1505  --size_;
1506  --end_;
1507 
1508  return CastIterator<C>( base, end_ );
1509 }
1510 //*************************************************************************************************
1511 
1512 
1513 //*************************************************************************************************
1523 template< typename T // Type
1524  , typename D // Deletion policy
1525  , typename G > // Growth policy
1527 {
1528  T** const base = const_cast<T**>( pos.base() );
1529  std::copy( base+1, end_, base );
1530 
1531  --size_;
1532  --end_;
1533 
1534  return pos;
1535 }
1536 //*************************************************************************************************
1537 
1538 
1539 //*************************************************************************************************
1549 template< typename T // Type
1550  , typename D // Deletion policy
1551  , typename G > // Growth policy
1552 template< typename C > // Cast type
1553 inline typename PtrVector<T,D,G>::BLAZE_TEMPLATE CastIterator<C>
1555 {
1556  T** const base = const_cast<T**>( pos.base() );
1557  std::copy( base+1, end_, base );
1558 
1559  --size_;
1560  --end_;
1561 
1562  return CastIterator<C>( base, end_ );
1563 }
1564 //*************************************************************************************************
1565 
1566 
1567 //*************************************************************************************************
1572 template< typename T // Type
1573  , typename D // Deletion policy
1574  , typename G > // Growth policy
1576 {
1577  for( PointerType* it=begin_; it!=end_; ++it )
1578  deleteElement( *it );
1579 
1580  end_ = begin_;
1581  size_ = 0;
1582 }
1583 //*************************************************************************************************
1584 
1585 
1586 
1587 
1588 //=================================================================================================
1589 //
1590 // UTILITY FUNCTIONS
1591 //
1592 //=================================================================================================
1593 
1594 //*************************************************************************************************
1600 template< typename T // Type
1601  , typename D // Deletion policy
1602  , typename G > // Growth policy
1604 {
1605  if( newCapacity > capacity_ )
1606  {
1607  // Calculating the new capacity
1608  newCapacity = calcCapacity( newCapacity );
1609 
1610  // Allocating a new array
1611  PointerType* tmp = new PointerType[newCapacity];
1612 
1613  // Replacing the old array
1614  std::copy( begin_, end_, tmp );
1615  std::swap( tmp, begin_ );
1616  capacity_ = newCapacity;
1617  end_ = begin_ + size_;
1618  delete [] tmp;
1619  }
1620 }
1621 //*************************************************************************************************
1622 
1623 
1624 //*************************************************************************************************
1631 template< typename T // Type
1632  , typename D // Deletion policy
1633  , typename G > // Growth policy
1634 inline void PtrVector<T,D,G>::swap( PtrVector& pv ) /* throw() */
1635 {
1636  // By using the 'std::swap' function to swap all member variables,
1637  // the function can give the nothrow guarantee.
1638  std::swap( size_, pv.size_ );
1639  std::swap( capacity_, pv.capacity_ );
1640  std::swap( begin_, pv.begin_ );
1641  std::swap( end_, pv.end_ );
1642 }
1643 //*************************************************************************************************
1644 
1645 
1646 
1647 
1648 //=================================================================================================
1649 //
1650 // HELPER FUNCTIONS
1651 //
1652 //=================================================================================================
1653 
1654 //*************************************************************************************************
1660 template< typename T // Type
1661  , typename D // Deletion policy
1662  , typename G > // Growth policy
1663 inline size_t PtrVector<T,D,G>::calcCapacity( size_t minCapacity ) const
1664 {
1665  BLAZE_INTERNAL_ASSERT( minCapacity > capacity_, "Invalid new vector capacity" );
1666  const size_t newCapacity( GrowthPolicy()( capacity_, minCapacity ) );
1667  BLAZE_INTERNAL_ASSERT( newCapacity > capacity_, "Invalid new vector capacity" );
1668  return newCapacity;
1669 }
1670 //*************************************************************************************************
1671 
1672 
1673 //*************************************************************************************************
1679 template< typename T // Type
1680  , typename D // Deletion policy
1681  , typename G > // Growth policy
1683 {
1684  DeletionPolicy()( ptr );
1685 }
1686 //*************************************************************************************************
1687 
1688 
1689 
1690 
1691 //=================================================================================================
1692 //
1693 // INSERTION HELPER FUNCTIONS
1694 //
1695 //=================================================================================================
1696 
1697 //*************************************************************************************************
1705 template< typename T // Type
1706  , typename D // Deletion policy
1707  , typename G > // Growth policy
1708 void PtrVector<T,D,G>::insert( T**const pos, PointerType p )
1709 {
1710  if( size_ != capacity_ ) {
1711  std::copy_backward( pos, end_, end_+1 );
1712  *pos = p;
1713  ++end_;
1714  ++size_;
1715  }
1716  else if( size_ == maxSize() ) {
1717  throw std::length_error( "Maximum pointer vector length exceeded!" );
1718  }
1719  else {
1720  SizeType newCapacity( calcCapacity( capacity_+1 ) );
1721  if( newCapacity > maxSize() || newCapacity < capacity_ ) newCapacity = maxSize();
1722 
1723  PointerType* newBegin = new PointerType[newCapacity];
1724  PointerType* newEnd = std::copy( begin_, pos, newBegin );
1725  *newEnd = p;
1726  ++newEnd;
1727  end_ = std::copy( pos, end_, newEnd );
1728 
1729  std::swap( newBegin, begin_ );
1730  delete [] newBegin;
1731  capacity_ = newCapacity;
1732  ++size_;
1733  }
1734 }
1735 //*************************************************************************************************
1736 
1737 
1738 //*************************************************************************************************
1751 template< typename T // Type
1752  , typename D // Deletion policy
1753  , typename G > // Growth policy
1754 template< typename IteratorType >
1755 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType first, IteratorType last,
1756  std::input_iterator_tag )
1757 {
1758  for( ; first!=last; ++first ) {
1759  pos = insert( pos, *first );
1760  ++pos;
1761  }
1762 }
1764 //*************************************************************************************************
1765 
1766 
1767 //*************************************************************************************************
1780 template< typename T // Type
1781  , typename D // Deletion policy
1782  , typename G > // Growth policy
1783 template< typename IteratorType >
1784 inline void PtrVector<T,D,G>::insert( Iterator pos, IteratorType first, IteratorType last,
1785  std::random_access_iterator_tag )
1786 {
1787  T** const base = const_cast<T**>( pos.base() );
1788  const SizeType diff( last - first );
1789 
1790  if( size_+diff <= capacity_ && base == end_ ) {
1791  for( ; first!=last; ++first, ++end_ ) {
1792  *end_ = *first;
1793  }
1794  size_ += diff;
1795  }
1796  else {
1797  insert( base, first, last, diff );
1798  }
1799 }
1801 //*************************************************************************************************
1802 
1803 
1804 //*************************************************************************************************
1814 template< typename T // Type
1815  , typename D // Deletion policy
1816  , typename G > // Growth policy
1817 template< typename IteratorType >
1818 void PtrVector<T,D,G>::insert( T** pos, IteratorType first, IteratorType last, SizeType n )
1819 {
1820  const SizeType newSize( size_ + n );
1821 
1822  if( newSize <= capacity_ ) {
1823  std::copy_backward( pos, end_, end_+n );
1824  for( ; first!=last; ++first, ++pos ) {
1825  *pos = *first;
1826  }
1827  end_ += n;
1828  size_ = newSize;
1829  }
1830  else if( newSize > maxSize() || newSize < size_ ) {
1831  throw std::length_error( "Maximum pointer vector length exceeded!" );
1832  }
1833  else {
1834  PointerType* newBegin = new PointerType[newSize];
1835  PointerType* newEnd = std::copy( begin_, pos, newBegin );
1836 
1837  for( ; first!=last; ++first, ++newEnd ) {
1838  *newEnd = *first;
1839  }
1840 
1841  end_ = std::copy( pos, end_, newEnd );
1842 
1843  std::swap( newBegin, begin_ );
1844  delete [] newBegin;
1845  capacity_ = newSize;
1846  size_ = newSize;
1847  }
1848 }
1849 //*************************************************************************************************
1850 
1851 
1852 
1853 
1854 //=================================================================================================
1855 //
1856 // GLOBAL OPERATORS
1857 //
1858 //=================================================================================================
1859 
1860 //*************************************************************************************************
1863 template< typename T, typename D, typename G >
1864 inline bool operator==( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs );
1865 
1866 template< typename T, typename D, typename G >
1867 inline bool operator!=( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs );
1868 
1869 template< typename T, typename D, typename G >
1870 inline void swap( PtrVector<T,D,G>& a, PtrVector<T,D,G>& b ) /* throw() */;
1872 //*************************************************************************************************
1873 
1874 
1875 //*************************************************************************************************
1882 template< typename T // Type
1883  , typename D // Deletion policy
1884  , typename G > // Growth policy
1885 inline bool operator==( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs )
1886 {
1887  return lhs.size() == rhs.size() && std::equal( lhs.begin(), lhs.end(), rhs.begin() );
1888 }
1889 //*************************************************************************************************
1890 
1891 
1892 //*************************************************************************************************
1899 template< typename T // Type
1900  , typename D // Deletion policy
1901  , typename G > // Growth policy
1902 inline bool operator!=( const PtrVector<T,D,G>& lhs, const PtrVector<T,D,G>& rhs )
1903 {
1904  return lhs.size() != rhs.size() || !std::equal( lhs.begin(), lhs.end(), rhs.begin() );
1905 }
1906 //*************************************************************************************************
1907 
1908 
1909 //*************************************************************************************************
1917 template< typename T // Type
1918  , typename D // Deletion policy
1919  , typename G > // Growth policy
1920 inline void swap( PtrVector<T,D,G>& a, PtrVector<T,D,G>& b ) /* throw() */
1921 {
1922  a.swap( b );
1923 }
1924 //*************************************************************************************************
1925 
1926 
1927 
1928 
1929 
1930 
1931 
1932 
1933 //=================================================================================================
1934 //
1935 // NESTED CLASS PTRVECTOR::CASTITERATOR
1936 //
1937 //=================================================================================================
1938 
1939 //*************************************************************************************************
1962 template< typename T // Type
1963  , typename D // Deletion policy
1964  , typename G > // Growth policy
1965 template< typename C > // Cast type
1966 class PtrVector<T,D,G>::CastIterator
1967 {
1968  public:
1969  //**Type definitions****************************************************************************
1970  // Blaze naming convention
1971  typedef std::forward_iterator_tag IteratorCategory;
1972  typedef C* ValueType;
1973  typedef C* PointerType;
1974  typedef C* const& ReferenceType;
1976  typedef T* const* IteratorType;
1977 
1978  // STL iterator requirements
1984  //**********************************************************************************************
1985 
1986  //**Constructors********************************************************************************
1989  inline CastIterator();
1991 
1992  template< typename Other >
1993  inline CastIterator( const CastIterator<Other>& it );
1994 
1995  // No explicitly declared copy constructor.
1997  //**********************************************************************************************
1998 
1999  //**Destructor**********************************************************************************
2000  // No explicitly declared destructor.
2001  //**********************************************************************************************
2002 
2003  //**Copy assignment operator********************************************************************
2004  // No explicitly declared copy assignment operator.
2005  //**********************************************************************************************
2006 
2007  //**Operators***********************************************************************************
2010  inline CastIterator& operator++();
2011  inline CastIterator operator++( int );
2013  //**********************************************************************************************
2014 
2015  //**Access operators****************************************************************************
2018  inline PointerType operator*() const;
2019  inline PointerType operator->() const;
2021  //**********************************************************************************************
2022 
2023  //**Utility functions***************************************************************************
2026  inline const IteratorType& base() const;
2027  inline const IteratorType& stop() const;
2029  //**********************************************************************************************
2030 
2031  private:
2032  //**Member variables****************************************************************************
2037 
2038  //**********************************************************************************************
2039 };
2040 //*************************************************************************************************
2041 
2042 
2043 
2044 
2045 //=================================================================================================
2046 //
2047 // CONSTRUCTOR
2048 //
2049 //=================================================================================================
2050 
2051 //*************************************************************************************************
2054 template< typename T // Type
2055  , typename D // Deletion policy
2056  , typename G > // Growth policy
2057 template< typename C > // Cast type
2059  : cur_(NULL) // Pointer to the current memory location
2060  , end_(NULL) // Pointer to the element one past the last element in the element range
2061 {
2063 }
2064 //*************************************************************************************************
2065 
2066 
2067 //*************************************************************************************************
2073 template< typename T // Type
2074  , typename D // Deletion policy
2075  , typename G > // Growth policy
2076 template< typename C > // Cast type
2078  : cur_(begin) // Pointer to the current memory location
2079  , end_(end) // Pointer to the element one past the last element in the element range
2080 {
2081  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2082  // contained in the range [cur_,end). An equivalent code might look like this:
2083  //
2084  // while( cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) ++cur_;
2085  //
2086  // However, the specialization of polymorphicFind() for special type combinations is much
2087  // more efficient (and way easier!) than the specialization of this function!
2088  cur_ = polymorphicFind<C>( cur_, end_ );
2089 }
2090 //*************************************************************************************************
2091 
2092 
2093 //*************************************************************************************************
2098 template< typename T // Type
2099  , typename D // Deletion policy
2100  , typename G > // Growth policy
2101 template< typename C > // Cast type
2102 template< typename Other > // The foreign cast iterator type
2104  : cur_( it.base() ) // Pointer to the current memory location
2105  , end_( it.stop() ) // Pointer to the element one past the last element in the element range
2106 {
2109 }
2110 //*************************************************************************************************
2111 
2112 
2113 
2114 
2115 //=================================================================================================
2116 //
2117 // OPERATORS
2118 //
2119 //=================================================================================================
2120 
2121 //*************************************************************************************************
2126 template< typename T // Type
2127  , typename D // Deletion policy
2128  , typename G > // Growth policy
2129 template< typename C > // Cast type
2132 {
2133  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2134  // contained in the range [cur_+1,end). An equivalent code might look like this:
2135  //
2136  // while( ++cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) {}
2137  //
2138  // However, the specialization of polymorphicFind() for special type combinations is much
2139  // more efficient (and way easier!) than the specialization of this function!
2140  cur_ = polymorphicFind<C>( ++cur_, end_ );
2141 
2142  return *this;
2143 }
2144 //*************************************************************************************************
2145 
2146 
2147 //*************************************************************************************************
2152 template< typename T // Type
2153  , typename D // Deletion policy
2154  , typename G > // Growth policy
2155 template< typename C > // Cast type
2158 {
2159  CastIterator tmp( *this );
2160 
2161  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2162  // contained in the range [cur_+1,end). An equivalent code might look like this:
2163  //
2164  // while( ++cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) {}
2165  //
2166  // However, the specialization of polymorphicFind() for special type combinations is much
2167  // more efficient (and way easier!) than the specialization of this function!
2168  cur_ = polymorphicFind<C>( ++cur_, end_ );
2169 
2170  return tmp;
2171 }
2172 //*************************************************************************************************
2173 
2174 
2175 
2176 
2177 //=================================================================================================
2178 //
2179 // ACCESS OPERATORS
2180 //
2181 //=================================================================================================
2182 
2183 //*************************************************************************************************
2188 template< typename T // Type
2189  , typename D // Deletion policy
2190  , typename G > // Growth policy
2191 template< typename C > // Cast type
2194 {
2195  return static_cast<C*>( *cur_ );
2196 }
2197 //*************************************************************************************************
2198 
2199 
2200 //*************************************************************************************************
2205 template< typename T // Type
2206  , typename D // Deletion policy
2207  , typename G > // Growth policy
2208 template< typename C > // Cast type
2211 {
2212  return static_cast<C*>( *cur_ );
2213 }
2214 //*************************************************************************************************
2215 
2216 
2217 
2218 
2219 //=================================================================================================
2220 //
2221 // UTILITY FUNCTIONS
2222 //
2223 //=================================================================================================
2224 
2225 //*************************************************************************************************
2230 template< typename T // Type
2231  , typename D // Deletion policy
2232  , typename G > // Growth policy
2233 template< typename C > // Cast type
2236 {
2237  return cur_;
2238 }
2239 //*************************************************************************************************
2240 
2241 
2242 //*************************************************************************************************
2247 template< typename T // Type
2248  , typename D // Deletion policy
2249  , typename G > // Growth policy
2250 template< typename C > // Cast type
2253 {
2254  return end_;
2255 }
2256 //*************************************************************************************************
2257 
2258 
2259 
2260 
2261 
2262 
2263 
2264 
2265 //=================================================================================================
2266 //
2267 // NESTED CLASS PTRVECTOR::CONSTCASTITERATOR
2268 //
2269 //=================================================================================================
2270 
2271 //*************************************************************************************************
2295 template< typename T // Type
2296  , typename D // Deletion policy
2297  , typename G > // Growth policy
2298 template< typename C > // Cast type
2299 class PtrVector<T,D,G>::ConstCastIterator
2300 {
2301  public:
2302  //**Type definitions****************************************************************************
2303  // Blaze naming convention
2304  typedef std::forward_iterator_tag IteratorCategory;
2305  typedef const C* ValueType;
2306  typedef const C* PointerType;
2307  typedef const C* const& ReferenceType;
2309  typedef const T* const* IteratorType;
2310 
2311  // STL iterator requirements
2317  //**********************************************************************************************
2318 
2319  //**Constructors********************************************************************************
2322  inline ConstCastIterator();
2324 
2325  template< typename Other >
2326  inline ConstCastIterator( const ConstCastIterator<Other>& it );
2327 
2328  template< typename Other >
2330 
2331  // No explicitly declared copy constructor.
2333  //**********************************************************************************************
2334 
2335  //**Destructor**********************************************************************************
2336  // No explicitly declared destructor.
2337  //**********************************************************************************************
2338 
2339  //**Copy assignment operator********************************************************************
2340  // No explicitly declared copy assignment operator.
2341  //**********************************************************************************************
2342 
2343  //**Operators***********************************************************************************
2346  inline ConstCastIterator& operator++();
2347  inline ConstCastIterator operator++( int );
2349  //**********************************************************************************************
2350 
2351  //**Access operators****************************************************************************
2354  inline PointerType operator*() const;
2355  inline PointerType operator->() const;
2357  //**********************************************************************************************
2358 
2359  //**Utility functions***************************************************************************
2362  inline const IteratorType& base() const;
2363  inline const IteratorType& stop() const;
2365  //**********************************************************************************************
2366 
2367  private:
2368  //**Member variables****************************************************************************
2373 
2374  //**********************************************************************************************
2375 };
2376 //*************************************************************************************************
2377 
2378 
2379 
2380 
2381 //=================================================================================================
2382 //
2383 // CONSTRUCTOR
2384 //
2385 //=================================================================================================
2386 
2387 //*************************************************************************************************
2390 template< typename T // Type
2391  , typename D // Deletion policy
2392  , typename G > // Growth policy
2393 template< typename C > // Cast type
2395  : cur_(NULL) // Pointer to the current memory location
2396  , end_(NULL) // Pointer to the element one past the last element in the element range
2397 {
2399 }
2400 //*************************************************************************************************
2401 
2402 
2403 //*************************************************************************************************
2409 template< typename T // Type
2410  , typename D // Deletion policy
2411  , typename G > // Growth policy
2412 template< typename C > // Cast type
2414  : cur_(begin) // Pointer to the current memory location
2415  , end_(end) // Pointer to the element one past the last element in the element range
2416 {
2417  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2418  // contained in the range [cur_,end). An equivalent code might look like this:
2419  //
2420  // while( cur_ != end_ && !dynamic_cast<C*>( *cur_ ) ) ++cur_;
2421  //
2422  // However, the specialization of polymorphicFind() for special type combinations is much
2423  // more efficient (and way easier!) than the specialization of this function!
2424  cur_ = polymorphicFind<C>( cur_, end_ );
2425 }
2426 //*************************************************************************************************
2427 
2428 
2429 //*************************************************************************************************
2434 template< typename T // Type
2435  , typename D // Deletion policy
2436  , typename G > // Growth policy
2437 template< typename C > // Cast type
2438 template< typename Other > // The foreign constant cast iterator type
2440  : cur_( it.base() ) // Pointer to the current memory location
2441  , end_( it.stop() ) // Pointer to the element one past the last element in the element range
2442 {
2445 }
2446 //*************************************************************************************************
2447 
2448 
2449 //*************************************************************************************************
2454 template< typename T // Type
2455  , typename D // Deletion policy
2456  , typename G > // Growth policy
2457 template< typename C > // Cast type
2458 template< typename Other > // The foreign cast iterator type
2460  : cur_( it.base() ) // Pointer to the current memory location
2461  , end_( it.stop() ) // Pointer to the element one past the last element in the element range
2462 {
2465 }
2466 //*************************************************************************************************
2467 
2468 
2469 
2470 
2471 //=================================================================================================
2472 //
2473 // OPERATORS
2474 //
2475 //=================================================================================================
2476 
2477 //*************************************************************************************************
2482 template< typename T // Type
2483  , typename D // Deletion policy
2484  , typename G > // Growth policy
2485 template< typename C > // Cast type
2488 {
2489  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2490  // contained in the range [cur_+1,end). An equivalent code might look like this:
2491  //
2492  // while( ++cur_ != end_ && !dynamic_cast<const C*>( *cur_ ) ) {}
2493  //
2494  // However, the specialization of polymorphicFind() for special type combinations is much
2495  // more efficient (and way easier!) than the specialization of this function!
2496  cur_ = polymorphicFind<const C>( ++cur_, end_ );
2497 
2498  return *this;
2499 }
2500 //*************************************************************************************************
2501 
2502 
2503 //*************************************************************************************************
2508 template< typename T // Type
2509  , typename D // Deletion policy
2510  , typename G > // Growth policy
2511 template< typename C > // Cast type
2514 {
2515  ConstCastIterator tmp( *this );
2516 
2517  // The polymorphicFind() function finds the next pointer to an object with dynamic type 'C'
2518  // contained in the range [cur_+1,end). An equivalent code might look like this:
2519  //
2520  // while( ++cur_ != end_ && !dynamic_cast<const C*>( *cur_ ) ) {}
2521  //
2522  // However, the specialization of polymorphicFind() for special type combinations is much
2523  // more efficient (and way easier!) than the specialization of this function!
2524  cur_ = polymorphicFind<const C>( ++cur_, end_ );
2525 
2526  return tmp;
2527 }
2528 //*************************************************************************************************
2529 
2530 
2531 
2532 
2533 //=================================================================================================
2534 //
2535 // ACCESS OPERATORS
2536 //
2537 //=================================================================================================
2538 
2539 //*************************************************************************************************
2544 template< typename T // Type
2545  , typename D // Deletion policy
2546  , typename G > // Growth policy
2547 template< typename C > // Cast type
2550 {
2551  return static_cast<const C*>( *cur_ );
2552 }
2553 //*************************************************************************************************
2554 
2555 
2556 //*************************************************************************************************
2561 template< typename T // Type
2562  , typename D // Deletion policy
2563  , typename G > // Growth policy
2564 template< typename C > // Cast type
2567 {
2568  return static_cast<const C*>( *cur_ );
2569 }
2570 //*************************************************************************************************
2571 
2572 
2573 
2574 
2575 //=================================================================================================
2576 //
2577 // UTILITY FUNCTIONS
2578 //
2579 //=================================================================================================
2580 
2581 //*************************************************************************************************
2586 template< typename T // Type
2587  , typename D // Deletion policy
2588  , typename G > // Growth policy
2589 template< typename C > // Cast type
2592 {
2593  return cur_;
2594 }
2595 //*************************************************************************************************
2596 
2597 
2598 //*************************************************************************************************
2603 template< typename T // Type
2604  , typename D // Deletion policy
2605  , typename G > // Growth policy
2606 template< typename C > // Cast type
2609 {
2610  return end_;
2611 }
2612 //*************************************************************************************************
2613 
2614 } // namespace blaze
2615 
2616 #endif
Pointer difference type of the Blaze library.
void swap(SymmetricMatrix< MT, SO, DF, NF > &a, SymmetricMatrix< MT, SO, DF, NF > &b)
Swapping the contents of two matrices.
Definition: SymmetricMatrix.h:195
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
DifferenceType difference_type
Difference between two iterators.
Definition: PtrVector.h:2316
void assign(IteratorType first, IteratorType last)
Assigning a range of elements to the pointer vector.
Definition: PtrVector.h:1364
friend bool operator==(const CastIterator< L > &lhs, const CastIterator< R > &rhs)
Equality comparison between two CastIterator objects.
Definition: PtrVector.h:474
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:4838
ReferenceType reference
Reference return type.
Definition: PtrVector.h:1982
IteratorType cur_
Pointer to the current memory location.
Definition: PtrVector.h:2371
ReferenceType reference
Reference to a non-const object.
Definition: PtrVector.h:309
friend bool operator!=(const ConstCastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Inequality comparison between two ConstCastIterator objects.
Definition: PtrVector.h:572
ConstReferenceType const_reference
Reference to a const object.
Definition: PtrVector.h:310
IteratorType end_
Pointer to the element one past the last element in the element range.
Definition: PtrVector.h:2036
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:258
Iterator insert(Iterator pos, PointerType p)
Inserting an element into the pointer vector.
Definition: PtrVector.h:1386
ReferenceType operator[](SizeType index)
Subscript operator for the direct access to the pointer vector elements.
Definition: PtrVector.h:889
Iterator begin()
Returns an iterator to the beginning of the pointer vector.
Definition: PtrVector.h:1002
void pushBack(PointerType p)
Adding an element to the end of the pointer vector.
Definition: PtrVector.h:1292
#define BLAZE_CONSTRAINT_MUST_BE_CONVERTIBLE(FROM, TO)
Constraint on the pointer relationship.In case FROM is not convertible to TO, a compilation error is ...
Definition: Convertible.h:78
void releaseBack()
Releasing the element at the end of the pointer vector.
Definition: PtrVector.h:1340
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: PtrVector.h:1975
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: PtrVector.h:1971
Iterator class for pointer vectors.
Iterator end()
Returns an iterator just past the last element of the pointer vector.
Definition: PtrVector.h:1144
#define BLAZE_CONSTRAINT_MUST_BE_STRICTLY_DERIVED_FROM(D, B)
Constraint on the inheritance relationship of a data type.In case D is not derived from B...
Definition: DerivedFrom.h:157
size_t SizeType
Size type of the pointer vector.
Definition: PtrVector.h:299
T *const * IteratorType
Type of the internal pointer.
Definition: PtrVector.h:1976
G GrowthPolicy
Type of the growth policy.
Definition: PtrVector.h:303
SizeType size_type
Size type of the pointer vector.
Definition: PtrVector.h:311
void clear()
Removing all elements from the pointer vector.
Definition: PtrVector.h:1575
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2638
friend bool operator!=(const CastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Inequality comparison between a CastIterator and a ConstCastIterator.
Definition: PtrVector.h:544
~PtrVector()
Destructor for PtrVector.
Definition: PtrVector.h:671
C *const & ReferenceType
Reference return type.
Definition: PtrVector.h:1974
SizeType capacity() const
Returns the capacity of the pointer vector.
Definition: PtrVector.h:848
Header file for the PtrDelete policy classes.
IteratorCategory iterator_category
The iterator category.
Definition: PtrVector.h:1979
IteratorType cur_
Pointer to the current memory location.
Definition: PtrVector.h:2035
Header file for nested template disabiguation.
Dynamic cast iterator for polymorphic pointer vectors.The ConstCastIterator class is part of the PtrV...
Definition: PtrVector.h:316
ReferenceType back()
Returns a reference to the last element of the pointer vector.
Definition: PtrVector.h:960
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4754
T * PointerType
Pointer to a non-const object.
Definition: PtrVector.h:295
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
PointerType pointer
Pointer return type.
Definition: PtrVector.h:1981
Constraint on the pointer relationship.
PtrVector(SizeType initCapacity=0)
Standard constructor for PtrVector.
Definition: PtrVector.h:602
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:2640
ValueType value_type
Type of the underlying pointers.
Definition: PtrVector.h:2313
ValueType value_type
Type of the underlying values.
Definition: PtrVector.h:306
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
friend bool operator==(const CastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Equality comparison between a CastIterator and a ConstCastIterator.
Definition: PtrVector.h:488
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: PtrVector.h:2304
C * PointerType
Pointer return type.
Definition: PtrVector.h:1973
friend bool operator==(const ConstCastIterator< L > &lhs, const ConstCastIterator< R > &rhs)
Equality comparison between two ConstCastIterator objects.
Definition: PtrVector.h:516
Constraint on the inheritance relationship of a data type.
const C *const & ReferenceType
Reference return type.
Definition: PtrVector.h:2307
Iterator release(Iterator pos)
Releasing an element from the pointer vector.
Definition: PtrVector.h:1526
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: PtrVector.h:2308
ReferenceType reference
Reference return type.
Definition: PtrVector.h:2315
PointerType pointer
Pointer return type.
Definition: PtrVector.h:2314
const C * PointerType
Pointer return type.
Definition: PtrVector.h:2306
bool isEmpty() const
Returns true if the pointer vector has no elements.
Definition: PtrVector.h:863
Headerfile for generic algorithms.
Implementation of an iterator for pointer vectors.The PtrIterator class follows the example of the ra...
Definition: PtrIterator.h:108
PointerType pointer
Pointer to a non-const object.
Definition: PtrVector.h:307
Dynamic cast iterator for polymorphic pointer vectors.The CastIterator class is part of the PtrVector...
Definition: PtrVector.h:315
void reserve(SizeType newCapacity)
Setting the minimum capacity of the pointer vector.
Definition: PtrVector.h:1603
SizeType capacity_
The capacity of the pointer vector.
Definition: PtrVector.h:452
SizeType size() const
Returns the current size of the pointer vector.
Definition: PtrVector.h:784
Header file for run time assertion macros.
PtrIterator< const T > ConstIterator
Iterator over const objects.
Definition: PtrVector.h:301
friend bool operator!=(const ConstCastIterator< L > &lhs, const CastIterator< R > &rhs)
Inequality comparison between a ConstCastIterator and a CastIterator.
Definition: PtrVector.h:558
bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:376
friend bool operator==(const ConstCastIterator< L > &lhs, const CastIterator< R > &rhs)
Equality comparison between a ConstCastIterator and a CastIterator.
Definition: PtrVector.h:502
Iterator erase(Iterator pos)
Removing an element from the pointer vector.
Definition: PtrVector.h:1469
T * ValueType
Type of the underlying values.
Definition: PtrVector.h:294
ValueType value_type
Type of the underlying pointers.
Definition: PtrVector.h:1980
PointerType * end_
Pointer to the last element of the pointer vector.
Definition: PtrVector.h:454
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
PointerType * begin_
Pointer to the first element of the pointer vector.
Definition: PtrVector.h:453
Implementation of a vector for (polymorphic) pointers.
Definition: PtrVector.h:282
IteratorType end_
Pointer to the element one past the last element in the element range.
Definition: PtrVector.h:2372
const IteratorType & base() const
Direct access to the current memory location of the cast iterator.
Definition: PtrVector.h:2235
T *const & ConstReferenceType
Reference to a const object.
Definition: PtrVector.h:298
D DeletionPolicy
Type of the deletion policy.
Definition: PtrVector.h:302
C * ValueType
Type of the underlying pointers.
Definition: PtrVector.h:1972
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:2639
const T *const * IteratorType
Type of the internal pointer.
Definition: PtrVector.h:2309
const T * ConstPointerType
Pointer to a const object.
Definition: PtrVector.h:296
ReferenceType front()
Returns a reference to the first element of the pointer vector.
Definition: PtrVector.h:924
size_t calcCapacity(size_t minCapacity) const
Calculating the new capacity of the vector based on its growth policy.
Definition: PtrVector.h:1663
T *& ReferenceType
Reference to a non-const object.
Definition: PtrVector.h:297
ConstPointerType const_pointer
Pointer to a const object.
Definition: PtrVector.h:308
friend bool operator!=(const CastIterator< L > &lhs, const CastIterator< R > &rhs)
Inequality comparison between two CastIterator objects.
Definition: PtrVector.h:530
SizeType maxSize() const
Returns the maximum possible size of a pointer vector.
Definition: PtrVector.h:769
const C * ValueType
Type of the underlying pointers.
Definition: PtrVector.h:2305
void popBack()
Removing an element from the end of the pointer vector.
Definition: PtrVector.h:1319
IteratorCategory iterator_category
The iterator category.
Definition: PtrVector.h:2312
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Header file for basic type definitions.
PtrVector & operator=(const PtrVector &pv)
Copy assignment operator for PtrVector.
Definition: PtrVector.h:697
void swap(PtrVector &pv)
Swapping the contents of two pointer vectors.
Definition: PtrVector.h:1634
Header file for the OptimalGrowth policy classes.
void deleteElement(PointerType ptr) const
Deleting an element of the pointer vector according to the deletion policy.
Definition: PtrVector.h:1682
Size type of the Blaze library.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
SizeType size_
The current size of the pointer vector.
Definition: PtrVector.h:451
const IteratorType & base() const
Access to the underlying member of the pointer iterator.
Definition: PtrIterator.h:434
PtrIterator< T > Iterator
Iterator over non-const objects.
Definition: PtrVector.h:300
Header file for a safe C++ NULL pointer implementation.
DifferenceType difference_type
Difference between two iterators.
Definition: PtrVector.h:1983