35 #ifndef _BLAZE_UTIL_SMALLARRAY_H_ 36 #define _BLAZE_UTIL_SMALLARRAY_H_ 80 ,
typename A = std::allocator<T> >
82 :
private SmallArrayData<T,N>
99 explicit inline SmallArray(
const A& alloc = A() );
100 explicit inline SmallArray(
size_t n,
const A& alloc = A() );
101 explicit inline SmallArray(
size_t n,
const T& init,
const A& alloc = A() );
103 template<
typename InputIt >
104 explicit inline SmallArray( InputIt first, InputIt last,
const A& alloc = A() );
106 template<
typename U >
142 template< typename U >
153 inline
bool empty() const noexcept;
154 inline
size_t size() const noexcept;
155 inline
size_t capacity() const noexcept;
159 void resize(
size_t n, const T& value );
269 std::uninitialized_fill(
begin_,
end_, init );
284 template<
typename InputIt >
288 std::uninitialized_copy( first, last,
begin_ );
312 template<
typename U >
316 std::uninitialized_copy( list.begin(), list.end(),
begin_ );
349 , final_( sa.final_ )
351 if( !sa.isDynamic() ) {
359 sa.begin_ = sa.array();
361 sa.final_ = sa.begin_ + N;
488 if( index >=
size() ) {
512 if( index >=
size() ) {
679 template<
typename U >
683 std::copy( list.begin(), list.end(),
begin_ );
724 std::move( rhs.begin_, rhs.end_,
begin_ );
727 rhs.begin_ = rhs.array();
728 rhs.end_ = rhs.begin_;
729 rhs.final_ = rhs.begin_ + N;
835 else if( n <
size() )
866 else if( n <
size() )
889 const size_t oldCapacity(
capacity() );
891 if( n > oldCapacity )
893 const size_t oldSize(
size() );
896 if( IsNothrowMoveConstructible_v<T> ) {
910 end_ = tmp + oldSize;
931 const size_t oldCapacity(
capacity() );
932 const size_t oldSize (
size() );
934 if( isDynamic() && oldCapacity > oldSize )
938 if( IsNothrowMoveConstructible_v<T> ) {
948 final_ = tmp + oldSize;
969 const size_t oldCapacity(
capacity() );
971 if(
size() == oldCapacity ) {
972 reserve(
max( 2UL*oldCapacity, 7UL ) );
975 ::new (
end_ ) T( value );
994 const size_t oldCapacity(
capacity() );
996 if(
size() == oldCapacity ) {
997 reserve(
max( 2UL*oldCapacity, 7UL ) );
1000 ::new (
end_ ) T( std::move( value ) );
1013 template<
typename T
1019 const size_t oldCapacity(
capacity() );
1020 const size_t oldSize (
size() );
1022 if( oldSize == oldCapacity )
1024 const size_t newCapacity(
max( 1UL, 2UL*oldCapacity ) );
1025 const size_t index( pos -
begin_ );
1027 T* tmp (
allocate( newCapacity ) );
1028 T* newpos( tmp + index );
1031 ::new ( newpos ) T( value );
1039 final_ = tmp + newCapacity;
1040 end_ = tmp + oldSize + 1UL;
1045 else if( pos ==
end_ )
1047 ::new( pos ) T( value );
1053 const auto tmp(
end_ - 1UL );
1054 ::new (
end_ ) T( std::move( *tmp ) );
1057 std::move_backward( pos, tmp,
end_ );
1059 ::new ( pos ) T( value );
1080 template<
typename T
1086 const size_t oldCapacity(
capacity() );
1087 const size_t oldSize (
size() );
1089 if( oldSize == oldCapacity )
1091 const size_t newCapacity(
max( 1UL, 2UL*oldCapacity ) );
1092 const size_t index( pos -
begin_ );
1094 T* tmp (
allocate( newCapacity ) );
1095 T* newpos( tmp + index );
1098 ::new ( newpos ) T( std::move( value ) );
1106 final_ = tmp + newCapacity;
1107 end_ = tmp + oldSize + 1UL;
1112 else if( pos ==
end_ )
1114 ::new( pos ) T( std::move( value ) );
1120 const auto tmp(
end_ - 1UL );
1121 ::new (
end_ ) T( std::move( *tmp ) );
1124 std::move_backward( pos, tmp,
end_ );
1126 ::new ( pos ) T( std::move( value ) );
1148 template<
typename T
1154 std::move( pos+1UL,
end_, pos );
1172 template<
typename T
1180 const size_t n( last - first );
1182 std::move( last,
end_, first );
1201 template<
typename T
1208 if( isDynamic() && sa.isDynamic() )
1212 swap( final_, sa.final_ );
1214 else if( isDynamic() )
1216 const size_t n( sa.size() );
1229 else if( sa.isDynamic() )
1231 const size_t n(
size() );
1240 sa.begin_ = sa.array();
1241 sa.end_ = sa.begin_ + n;
1242 sa.final_ = sa.begin_ + N;
1244 else if(
size() > sa.size() )
1246 const size_t n(
size() - sa.size() );
1247 const auto pos = std::swap_ranges( sa.begin_, sa.end_,
begin_ );
1256 const size_t n( sa.size() -
size() );
1257 const auto pos = std::swap_ranges(
begin_,
end_, sa.begin_ );
1273 template<
typename T
1278 return ( N == 0UL ||
begin_ != this->array() );
1294 template<
typename T1,
size_t N1,
typename A1,
typename T2,
size_t N2,
typename A2 >
1297 template<
typename T1,
size_t N1,
typename A1,
typename T2,
size_t N2,
typename A2 >
1300 template<
typename T,
size_t N,
typename A >
1303 template<
typename T,
size_t N,
typename A >
1306 template<
typename T,
size_t N,
typename A >
1309 template<
typename T,
size_t N,
typename A >
1312 template<
typename T,
size_t N,
typename A >
1315 template<
typename T,
size_t N,
typename A >
1318 template<
typename T,
size_t N,
typename A >
1321 template<
typename T,
size_t N,
typename A >
1323 noexcept( IsNothrowMoveConstructible_v<T> );
1336 template<
typename T1
1344 if( lhs.
size() != rhs.
size() )
return false;
1359 template<
typename T1
1367 return !( lhs == rhs );
1379 template<
typename T,
size_t N,
typename A >
1394 template<
typename T,
size_t N,
typename A >
1409 template<
typename T,
size_t N,
typename A >
1424 template<
typename T,
size_t N,
typename A >
1439 template<
typename T,
size_t N,
typename A >
1454 template<
typename T,
size_t N,
typename A >
1469 template<
typename T
1491 template<
typename T
1495 noexcept( IsNothrowMoveConstructible_v<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.
Definition of the nested auxiliary struct Uninitialized.
Definition: SmallArray.h:176
const T * ConstIterator
Iterator over constant elements.
Definition: SmallArray.h:93
#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
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the array elements.
Definition: SmallArray.h:443
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
Header file for exception macros.
Iterator insert(Iterator pos, const T &value)
Inserting an element at the specified position into the small array.
Definition: SmallArray.h:1017
T ElementType
Type of the array elements.
Definition: SmallArray.h:87
#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
~SmallArray()
The destructor for SmallArray.
Definition: SmallArray.h:410
bool isDynamic() const noexcept
Returns whether the small array uses its dynamic storage.
Definition: SmallArray.h:1276
const T & ConstReference
Reference to a constant array element.
Definition: SmallArray.h:91
void clear()
Clearing the array.
Definition: SmallArray.h:799
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
void swap(SmallArray &sa) noexcept(IsNothrowMoveConstructible_v< T >)
Swapping the contents of two small arrays.
Definition: SmallArray.h:1204
bool empty() const noexcept
Returns whether the array is empty.
Definition: SmallArray.h:752
Header file for the initializer_list template.
constexpr bool IsNothrowMoveConstructible_v
Auxiliary variable template for the IsNothrowMoveConstructible type trait.The IsNothrowMoveConstructi...
Definition: IsConstructible.h:427
Headerfile for the generic max algorithm.
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:5907
Headerfile for the generic destroy_at algorithm.
Reference at(size_t index)
Checked access to the array elements.
Definition: SmallArray.h:486
T * begin_
Pointer to the beginning of the currently used storage.
Definition: SmallArray.h:199
Headerfile for the generic uninitialized_move algorithm.
Implementation of a dynamic array with small array optimization.The SmallArray class template is a hy...
Definition: SmallArray.h:81
Pointer data() noexcept
Low-level data access to the array elements.
Definition: SmallArray.h:531
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
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:3293
#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:253
Constraint on the data type.
Header file for the IsConstructible type trait.
void reserve(size_t n)
Setting the minimum capacity of the array.
Definition: SmallArray.h:887
Iterator erase(Iterator pos)
Erasing an element from the small array.
Definition: SmallArray.h:1152
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the small array.
Definition: SmallArray.h:597
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
void destroy(ForwardIt first, ForwardIt last)
Destroys the given range of objects .
Definition: Destroy.h:66
void resize(size_t n)
Changing the size of the array.
Definition: SmallArray.h:827
T * end_
Pointer to the end of the currently used storage.
Definition: SmallArray.h:200
void pushBack(const T &value)
Adding an element to the end of the small array.
Definition: SmallArray.h:965
size_t size() const noexcept
Returns the current size/dimension of the small array.
Definition: SmallArray.h:767
Header file for run time assertion macros.
Iterator begin() noexcept
Returns an iterator to the first element of the small array.
Definition: SmallArray.h:565
void shrinkToFit()
Requesting the removal of unused capacity.
Definition: SmallArray.h:929
Constraint on the data type.
size_t capacity() const noexcept
Returns the maximum capacity of the small array.
Definition: SmallArray.h:782
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
SmallArray(const A &alloc=A())
The (default) constructor for SmallArray.
Definition: SmallArray.h:231
Header file for the IsAssignable type trait.
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:3292
T & Reference
Reference to a non-constant array element.
Definition: SmallArray.h:90
void uninitialized_default_construct(ForwardIt first, ForwardIt last)
Default constructs elements in the given range.
Definition: UninitializedDefaultConstruct.h:67
T * Iterator
Iterator over non-constant elements.
Definition: SmallArray.h:92
EnableIf_t< IsBuiltin_v< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:224
T * Pointer
Pointer to a non-constant array element.
Definition: SmallArray.h:88
Iterator end() noexcept
Returns an iterator just past the last element of the small array.
Definition: SmallArray.h:613
Initializer list type of the Blaze library.
Header file for the SmallArrayData class template.
void destroy_at(T *p) noexcept
Destroys the object at the given address.
Definition: DestroyAt.h:57
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the small array.
Definition: SmallArray.h:645
EnableIf_t< IsBuiltin_v< T >, T *> allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:156
T * final_
Pointer to the very end of the currently used storage.
Definition: SmallArray.h:201
bool equal(const SharedValue< T1 > &lhs, const SharedValue< T2 > &rhs)
Equality check for a two shared values.
Definition: SharedValue.h:342
const T * ConstPointer
Pointer to a constant array element.
Definition: SmallArray.h:89