22 #ifndef _BLAZE_UTIL_PTRVECTOR_H_
23 #define _BLAZE_UTIL_PTRVECTOR_H_
267 ,
typename D = PtrDelete
268 ,
typename G = OptimalGrowth >
274 template<
typename T2,
typename D2,
typename G2 >
friend class PtrVector;
312 template<
typename T2,
typename D2,
typename G2 >
313 inline PtrVector(
const PtrVector<T2,D2,G2>& pv );
329 template<
typename T2,
typename D2,
typename G2 >
379 template<
typename IteratorType >
380 inline void assign( IteratorType first, IteratorType last );
384 template<
typename IteratorType >
385 inline void insert(
Iterator pos, IteratorType first, IteratorType last );
388 template<
typename IteratorType >
389 inline void insert(
Iterator pos, IteratorType* first, IteratorType* last );
396 inline void clear ();
412 inline size_t calcCapacity (
size_t minCapacity )
const;
423 template<
typename IteratorType >
424 inline void insert(
Iterator pos, IteratorType first, IteratorType last, std::input_iterator_tag );
426 template<
typename IteratorType >
427 inline void insert(
Iterator pos, IteratorType first, IteratorType last, std::random_access_iterator_tag );
430 template<
typename IteratorType >
431 void insert( T** pos, IteratorType first, IteratorType last,
SizeType n );
460 template<
typename L,
typename R >
463 return lhs.base() == rhs.base();
474 template<
typename L,
typename R >
477 return lhs.base() == rhs.base();
488 template<
typename L,
typename R >
491 return lhs.base() == rhs.base();
502 template<
typename L,
typename R >
505 return lhs.base() == rhs.base();
516 template<
typename L,
typename R >
519 return lhs.base() != rhs.base();
530 template<
typename L,
typename R >
533 return lhs.base() != rhs.base();
544 template<
typename L,
typename R >
547 return lhs.base() != rhs.base();
558 template<
typename L,
typename R >
561 return lhs.base() != rhs.base();
591 , capacity_( initCapacity )
608 , capacity_( pv.size_ )
610 , end_( begin_+size_ )
626 template<
typename T2
631 , capacity_( pv.size_ )
633 , end_( begin_+size_ )
661 deleteElement( *it );
686 if( &pv ==
this )
return *
this;
688 if( pv.
size_ > capacity_ ) {
690 end_ = std::copy( pv.
begin_, pv.
end_, newBegin );
695 capacity_ = pv.
size_;
698 end_ = std::copy( pv.
begin_, pv.
end_, begin_ );
716 template<
typename T2
721 if( pv.
size_ > capacity_ ) {
723 end_ = std::copy( pv.
begin_, pv.
end_, newBegin );
728 capacity_ = pv.
size_;
731 end_ = std::copy( pv.
begin_, pv.
end_, begin_ );
809 template<
typename C >
822 return polymorphicCount<C>( begin_, end_ );
878 return *(begin_+index);
896 return *(begin_+index);
913 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the front element" );
931 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the front element" );
949 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the back element" );
967 BLAZE_USER_ASSERT( size_ > 0,
"Pointer vector is empty, invalid access to the back element" );
1001 template<
typename T
1056 template<
typename T
1059 template<
typename C >
1112 template<
typename T
1115 template<
typename C >
1128 template<
typename T
1143 template<
typename T
1195 template<
typename T
1198 template<
typename C >
1248 template<
typename T
1251 template<
typename C >
1276 template<
typename T
1281 if( size_ != capacity_ ) {
1303 template<
typename T
1308 deleteElement( *--end_ );
1324 template<
typename T
1347 template<
typename T
1350 template<
typename IteratorType >
1354 insert( end(), first, last );
1370 template<
typename T
1375 T**
const base =
const_cast<T**
>( pos.
base() );
1376 const SizeType diff( base - begin_ );
1378 if( size_ != capacity_ && base == end_ ) {
1405 template<
typename T
1408 template<
typename IteratorType >
1411 insert( pos, first, last,
typename IteratorType::iterator_category() );
1430 template<
typename T
1433 template<
typename IteratorType >
1436 insert( pos, first, last, std::random_access_iterator_tag() );
1453 template<
typename T
1458 T**
const base =
const_cast<T**
>( pos.
base() );
1459 deleteElement( *base );
1460 std::copy( base+1, end_, base );
1481 template<
typename T
1484 template<
typename C >
1488 T**
const base =
const_cast<T**
>( pos.
base() );
1489 deleteElement( *base );
1490 std::copy( base+1, end_, base );
1510 template<
typename T
1515 T**
const base =
const_cast<T**
>( pos.
base() );
1516 std::copy( base+1, end_, base );
1536 template<
typename T
1539 template<
typename C >
1543 T**
const base =
const_cast<T**
>( pos.
base() );
1544 std::copy( base+1, end_, base );
1559 template<
typename T
1565 deleteElement( *it );
1587 template<
typename T
1592 if( newCapacity > capacity_ )
1595 newCapacity = calcCapacity( newCapacity );
1601 std::copy( begin_, end_, tmp );
1603 capacity_ = newCapacity;
1604 end_ = begin_ + size_;
1618 template<
typename T
1647 template<
typename T
1653 const size_t newCapacity(
GrowthPolicy()( capacity_, minCapacity ) );
1666 template<
typename T
1692 template<
typename T
1697 if( size_ != capacity_ ) {
1698 std::copy_backward( pos, end_, end_+1 );
1703 else if( size_ == maxSize() ) {
1704 throw std::length_error(
"Maximum pointer vector length exceeded!" );
1707 SizeType newCapacity( calcCapacity( capacity_+1 ) );
1708 if( newCapacity > maxSize() || newCapacity < capacity_ ) newCapacity = maxSize();
1711 PointerType* newEnd = std::copy( begin_, pos, newBegin );
1714 end_ = std::copy( pos, end_, newEnd );
1718 capacity_ = newCapacity;
1738 template<
typename T
1741 template<
typename IteratorType >
1743 std::input_iterator_tag )
1745 for( ; first!=last; ++first ) {
1746 pos = insert( pos, *first );
1767 template<
typename T
1770 template<
typename IteratorType >
1772 std::random_access_iterator_tag )
1774 T**
const base =
const_cast<T**
>( pos.base() );
1775 const SizeType diff( last - first );
1777 if( size_+diff <= capacity_ && base == end_ ) {
1778 for( ; first!=last; ++first, ++end_ ) {
1784 insert( base, first, last, diff );
1801 template<
typename T
1804 template<
typename IteratorType >
1807 const SizeType newSize( size_ + n );
1809 if( newSize <= capacity_ ) {
1810 std::copy_backward( pos, end_, end_+n );
1811 for( ; first!=last; ++first, ++pos ) {
1817 else if( newSize > maxSize() || newSize < size_ ) {
1818 throw std::length_error(
"Maximum pointer vector length exceeded!" );
1822 PointerType* newEnd = std::copy( begin_, pos, newBegin );
1824 for( ; first!=last; ++first, ++newEnd ) {
1828 end_ = std::copy( pos, end_, newEnd );
1832 capacity_ = newSize;
1850 template<
typename T,
typename D,
typename G >
1853 template<
typename T,
typename D,
typename G >
1856 template<
typename T,
typename D,
typename G >
1869 template<
typename T
1886 template<
typename T
1904 template<
typename T
1949 template<
typename T
1952 template<
typename C >
1979 template<
typename Other >
2041 template<
typename T
2044 template<
typename C >
2060 template<
typename T
2063 template<
typename C >
2085 template<
typename T
2088 template<
typename C >
2089 template<
typename Other >
2113 template<
typename T
2116 template<
typename C >
2127 cur_ = polymorphicFind<C>( ++cur_,
end_ );
2139 template<
typename T
2142 template<
typename C >
2155 cur_ = polymorphicFind<C>( ++cur_,
end_ );
2175 template<
typename T
2178 template<
typename C >
2182 return static_cast<C*
>( *cur_ );
2192 template<
typename T
2195 template<
typename C >
2199 return static_cast<C*
>( *cur_ );
2217 template<
typename T
2220 template<
typename C >
2234 template<
typename T
2237 template<
typename C >
2282 template<
typename T
2285 template<
typename C >
2312 template<
typename Other >
2315 template<
typename Other >
2377 template<
typename T
2380 template<
typename C >
2396 template<
typename T
2399 template<
typename C >
2421 template<
typename T
2424 template<
typename C >
2425 template<
typename Other >
2441 template<
typename T
2444 template<
typename C >
2445 template<
typename Other >
2469 template<
typename T
2472 template<
typename C >
2483 cur_ = polymorphicFind<const C>( ++cur_,
end_ );
2495 template<
typename T
2498 template<
typename C >
2511 cur_ = polymorphicFind<const C>( ++cur_,
end_ );
2531 template<
typename T
2534 template<
typename C >
2538 return static_cast<const C*
>( *cur_ );
2548 template<
typename T
2551 template<
typename C >
2555 return static_cast<const C*
>( *cur_ );
2573 template<
typename T
2576 template<
typename C >
2590 template<
typename T
2593 template<
typename C >