35 #ifndef _BLAZE_UTIL_SMALLVECTOR_H_ 36 #define _BLAZE_UTIL_SMALLVECTOR_H_ 79 ,
typename A = std::allocator<T> >
97 explicit inline SmallVector(
const A& alloc = A() );
98 explicit inline SmallVector(
size_t n,
const A& alloc = A() );
99 explicit inline SmallVector(
size_t n,
const T& init,
const A& alloc = A() );
101 template<
typename InputIt >
102 explicit inline SmallVector( InputIt first, InputIt last,
const A& alloc = A() );
104 template<
typename U >
140 template< typename U >
151 inline
bool empty() const noexcept;
152 inline
size_t size() const noexcept;
153 inline
size_t capacity() const noexcept;
157 void resize(
size_t n, const T& value );
196 enum :
size_t { NN = N > 0UL ? N*
sizeof(T) : 1UL };
274 std::uninitialized_fill(
begin_,
end_, init );
289 template<
typename InputIt >
293 std::uninitialized_copy( first, last,
begin_ );
317 template<
typename U >
321 std::uninitialized_copy( list.begin(), list.end(),
begin_ );
357 if( !sv.isDynamic() ) {
358 begin_ =
reinterpret_cast<T*
>(
v_ );
364 sv.begin_ =
reinterpret_cast<T*
>( sv.v_ );
366 sv.final_ = sv.begin_ + N;
388 begin_ =
reinterpret_cast<T*
>(
v_ );
495 if( index >=
size() ) {
519 if( index >=
size() ) {
686 template<
typename U >
690 std::copy( list.begin(), list.end(),
begin_ );
731 std::move( rhs.begin(), rhs.end(),
begin_ );
811 begin_ =
reinterpret_cast<T*
>(
v_ );
841 else if( n <
size() )
874 else if( n <
size() )
899 const size_t oldCapacity(
capacity() );
901 if( n > oldCapacity )
903 const size_t oldSize(
size() );
920 end_ = tmp + oldSize;
943 const size_t oldCapacity(
capacity() );
944 const size_t oldSize (
size() );
946 if(
isDynamic() && oldCapacity > oldSize )
981 const size_t oldCapacity(
capacity() );
983 if(
size() == oldCapacity ) {
987 ::new (
end_ ) T( value );
1006 const size_t oldCapacity(
capacity() );
1008 if(
size() == oldCapacity ) {
1012 ::new (
end_ ) T( std::move( value ) );
1025 template<
typename T
1033 const size_t oldCapacity(
capacity() );
1034 const size_t oldSize (
size() );
1036 if( oldSize == oldCapacity )
1038 const size_t newCapacity( 2UL*oldCapacity );
1039 const size_t index( pos -
begin_ );
1041 T* tmp (
allocate( newCapacity ) );
1042 T* newpos( tmp + index );
1045 ::new ( newpos ) T( value );
1053 final_ = tmp + newCapacity;
1054 end_ = tmp + oldSize + 1UL;
1059 else if( pos ==
end_ )
1061 ::new( pos ) T( value );
1067 const auto tmp(
end_ - 1UL );
1068 ::new (
end_ ) T( std::move( *tmp ) );
1071 std::move_backward( pos, tmp,
end_ );
1073 ::new ( pos ) T( value );
1094 template<
typename T
1102 const size_t oldCapacity(
capacity() );
1103 const size_t oldSize (
size() );
1105 if( oldSize == oldCapacity )
1107 const size_t newCapacity( 2UL*oldCapacity );
1108 const size_t index( pos -
begin_ );
1110 T* tmp (
allocate( newCapacity ) );
1111 T* newpos( tmp + index );
1114 ::new ( newpos ) T( std::move( value ) );
1122 final_ = tmp + newCapacity;
1123 end_ = tmp + oldSize + 1UL;
1128 else if( pos ==
end_ )
1130 ::new( pos ) T( std::move( value ) );
1136 const auto tmp(
end_ - 1UL );
1137 ::new (
end_ ) T( std::move( *tmp ) );
1140 std::move_backward( pos, tmp,
end_ );
1142 ::new ( pos ) T( std::move( value ) );
1164 template<
typename T
1170 std::move( pos+1UL,
end_, pos );
1188 template<
typename T
1198 const size_t n( last - first );
1200 std::move( last,
end_, first );
1219 template<
typename T
1235 const size_t n( sv.size() );
1238 destroy( sv.begin_, sv.end_ );
1244 begin_ =
reinterpret_cast<T*
>(
v_ );
1248 else if( sv.isDynamic() )
1250 const size_t n(
size() );
1259 sv.begin_ =
reinterpret_cast<T*
>( sv.v_ );
1260 sv.end_ = sv.begin_ + n;
1261 sv.final_ = sv.begin_ + N;
1263 else if(
size() > sv.size() )
1265 const size_t n(
size() - sv.size() );
1266 const auto pos = std::swap_ranges( sv.begin_, sv.end_,
begin_ );
1275 const size_t n( sv.size() -
size() );
1276 const auto pos = std::swap_ranges(
begin_,
end_, sv.begin_ );
1292 template<
typename T
1297 return begin_ !=
reinterpret_cast<const T*
>(
v_ );
1313 template<
typename T1,
size_t N1,
typename A1,
typename T2,
size_t N2,
typename A2 >
1316 template<
typename T1,
size_t N1,
typename A1,
typename T2,
size_t N2,
typename A2 >
1319 template<
typename T,
size_t N,
typename A >
1322 template<
typename T,
size_t N,
typename A >
1325 template<
typename T,
size_t N,
typename A >
1328 template<
typename T,
size_t N,
typename A >
1331 template<
typename T,
size_t N,
typename A >
1334 template<
typename T,
size_t N,
typename A >
1337 template<
typename T,
size_t N,
typename A >
1340 template<
typename T,
size_t N,
typename A >
1355 template<
typename T1
1363 if( lhs.
size() != rhs.
size() )
return false;
1378 template<
typename T1
1386 return !( lhs == rhs );
1398 template<
typename T,
size_t N,
typename A >
1413 template<
typename T,
size_t N,
typename A >
1428 template<
typename T,
size_t N,
typename A >
1443 template<
typename T,
size_t N,
typename A >
1458 template<
typename T,
size_t N,
typename A >
1473 template<
typename T,
size_t N,
typename A >
1488 template<
typename T
1510 template<
typename T
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
Headerfile for the generic destroy algorithm.
T * begin_
Pointer to the beginning of the currently used storage.
Definition: SmallVector.h:204
#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
Header file for the AlignmentOf type trait.
byte_t v_[NN]
The static storage.
Definition: SmallVector.h:202
Header file for basic type definitions.
const T & ConstReference
Reference to a constant vector element.
Definition: SmallVector.h:89
constexpr bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:76
unsigned char byte_t
Byte data type of the Blaze library.The byte data type is guaranteed to be an integral data type of s...
Definition: Types.h:79
void clear()
Clearing the vector.
Definition: SmallVector.h:801
Iterator end() noexcept
Returns an iterator just past the last element of the small vector.
Definition: SmallVector.h:620
Header file for exception macros.
T & Reference
Reference to a non-constant vector element.
Definition: SmallVector.h:88
Implementation of a dynamic vector with small vector optimization.The SmallVector class template is a...
Definition: SmallVector.h:80
bool isDynamic() const noexcept
Returns whether the small vector uses its dynamic storage.
Definition: SmallVector.h:1295
Reference at(size_t index)
Checked access to the vector elements.
Definition: SmallVector.h:493
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
bool empty() const noexcept
Returns whether the vector is empty.
Definition: SmallVector.h:754
T * Pointer
Pointer to a non-constant vector element.
Definition: SmallVector.h:86
void resize(size_t n)
Changing the size of the vector.
Definition: SmallVector.h:831
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
T * Iterator
Iterator over non-constant elements.
Definition: SmallVector.h:90
EnableIf_< IsBuiltin< T >, T *> allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:155
Header file for the initializer_list template.
Pointer data() noexcept
Low-level data access to the vector elements.
Definition: SmallVector.h:538
Headerfile for the generic max algorithm.
~SmallVector()
The destructor for DynamicVector.
Definition: SmallVector.h:415
Headerfile for the generic uninitialized_default_construct algorithm.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5908
T ElementType
Type of the vector elements.
Definition: SmallVector.h:85
Headerfile for the generic destroy_at algorithm.
Headerfile for the generic uninitialized_move algorithm.
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition: SmallVector.h:450
ForwardIt uninitialized_move(InputIt first, InputIt last, ForwardIt dest)
Move the elements from the given source range to the uninitialized destination range.
Definition: UninitializedMove.h:70
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Constraint on the data type.
size_t capacity() const noexcept
Returns the maximum capacity of the small vector.
Definition: SmallVector.h:784
Header file for the IsConstructible type trait.
T * end_
Pointer to the end of the currently used storage.
Definition: SmallVector.h:205
void shrinkToFit()
Requesting the removal of unused capacity.
Definition: SmallVector.h:939
Definition of the nested auxiliary struct Uninitialized.
Definition: SmallVector.h:174
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
void destroy(ForwardIt first, ForwardIt last)
Destroys the given range of objects .
Definition: Destroy.h:66
void swap(SmallVector &sv) noexcept(IsNothrowMoveConstructible< T >::value)
Swapping the contents of two small vectors.
Definition: SmallVector.h:1222
Header file for run time assertion macros.
Constraint on the data type.
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the small vector.
Definition: SmallVector.h:652
const T * ConstIterator
Iterator over constant elements.
Definition: SmallVector.h:91
size_t size() const noexcept
Returns the current size/dimension of the small vector.
Definition: SmallVector.h:769
void reserve(size_t n)
Setting the minimum capacity of the vector.
Definition: SmallVector.h:895
const T * ConstPointer
Pointer to a constant vector element.
Definition: SmallVector.h:87
Header file for the IsAssignable type trait.
SmallVector(const A &alloc=A())
The (default) constructor for SmallVector.
Definition: SmallVector.h:236
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:230
Compile time type check.The IsNothrowMoveConstructible type trait tests whether the expression...
Definition: IsConstructible.h:281
T * final_
Pointer to the very end of the currently used storage.
Definition: SmallVector.h:206
void uninitialized_default_construct(ForwardIt first, ForwardIt last)
Default constructs elements in the given range.
Definition: UninitializedDefaultConstruct.h:67
Iterator erase(Iterator pos)
Erasing an element from the small vector.
Definition: SmallVector.h:1168
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the small vector.
Definition: SmallVector.h:604
Initializer list type of the Blaze library.
Iterator begin() noexcept
Returns an iterator to the first element of the small vector.
Definition: SmallVector.h:572
void destroy_at(T *p) noexcept
Destroys the object at the given address.
Definition: DestroyAt.h:57
void pushBack(const T &value)
Adding an element to the end of the small vector.
Definition: SmallVector.h:977
Evaluation of the required alignment of the given data type.The AlignmentOf type trait template evalu...
Definition: AlignmentOf.h:219
Iterator insert(Iterator pos, const T &value)
Inserting an element at the specified position into the small vector.
Definition: SmallVector.h:1029