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 inline SmallArray(
size_t n,
const T& init,
const A& alloc = A() );
103 template<
typename InputIt >
104 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 );
284template<
typename InputIt >
288 std::uninitialized_copy( first, last,
begin_ );
312template<
typename U >
316 std::uninitialized_copy( list.begin(), list.end(),
begin_ );
351 if( !sa.isDynamic() ) {
352 begin_ = this->array();
353 end_ = begin_ + sa.size();
355 blaze::uninitialized_move( sa.begin_, sa.end_, begin_ );
356 blaze::destroy( sa.begin_, sa.end_ );
359 sa.begin_ = sa.array();
361 sa.final_ = sa.begin_ + N;
488 if( index >=
size() ) {
512 if( index >=
size() ) {
679template<
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() );
910 end_ = tmp + oldSize;
931 const size_t oldCapacity(
capacity() );
932 const size_t oldSize (
size() );
934 if(
isDynamic() && oldCapacity > oldSize )
969 const size_t oldCapacity(
capacity() );
971 if(
size() == oldCapacity ) {
975 ::new (
end_ ) T( value );
994 const size_t oldCapacity(
capacity() );
996 if(
size() == oldCapacity ) {
1000 ::new (
end_ ) T( std::move( value ) );
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 );
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 ) );
1154 std::move( pos+1UL,
end_, pos );
1180 const size_t n( last - first );
1182 std::move( last,
end_, first );
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_ );
1278 return ( N == 0UL ||
begin_ != this->array() );
1294template<
typename T1,
size_t N1,
typename A1,
typename T2,
size_t N2,
typename A2 >
1297template<
typename T1,
size_t N1,
typename A1,
typename T2,
size_t N2,
typename A2 >
1300template<
typename T,
size_t N,
typename A >
1303template<
typename T,
size_t N,
typename A >
1306template<
typename T,
size_t N,
typename A >
1309template<
typename T,
size_t N,
typename A >
1312template<
typename T,
size_t N,
typename A >
1315template<
typename T,
size_t N,
typename A >
1318template<
typename T,
size_t N,
typename A >
1321template<
typename T,
size_t N,
typename A >
1336template<
typename T1
1344 if( lhs.
size() != rhs.
size() )
return false;
1359template<
typename T1
1367 return !( lhs == rhs );
1379template<
typename T,
size_t N,
typename A >
1394template<
typename T,
size_t N,
typename A >
1409template<
typename T,
size_t N,
typename A >
1424template<
typename T,
size_t N,
typename A >
1439template<
typename T,
size_t N,
typename A >
1454template<
typename T,
size_t N,
typename A >
Header file for run time assertion macros.
Constraint on the data type.
Header file for the generic destroy_at algorithm.
Header file for the generic destroy algorithm.
Header file for the IsAssignable type trait.
Header file for the IsConstructible type trait.
Header file for the SmallArrayData class template.
Header file for the generic uninitialized_default_construct algorithm.
Header file for the generic uninitialized_move algorithm.
Constraint on the data type.
Implementation of a dynamic array with small array optimization.
Definition SmallArray.h:84
ConstIterator cbegin() const noexcept
Returns an iterator to the first element of the small array.
Definition SmallArray.h:597
void pushBack(const T &value)
Adding an element to the end of the small array.
Definition SmallArray.h:965
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the array elements.
Definition SmallArray.h:443
T * begin_
Pointer to the beginning of the currently used storage.
Definition SmallArray.h:199
Iterator insert(Iterator pos, const T &value)
Inserting an element at the specified position into the small array.
Definition SmallArray.h:1017
void reserve(size_t n)
Setting the minimum capacity of the array.
Definition SmallArray.h:887
void shrinkToFit()
Requesting the removal of unused capacity.
Definition SmallArray.h:929
const T * ConstPointer
Pointer to a constant array element.
Definition SmallArray.h:89
T * final_
Pointer to the very end of the currently used storage.
Definition SmallArray.h:201
Pointer data() noexcept
Low-level data access to the array elements.
Definition SmallArray.h:531
ConstIterator cend() const noexcept
Returns an iterator just past the last element of the small array.
Definition SmallArray.h:645
size_t capacity() const noexcept
Returns the maximum capacity of the small array.
Definition SmallArray.h:782
T * Pointer
Pointer to a non-constant array element.
Definition SmallArray.h:88
T ElementType
Type of the array elements.
Definition SmallArray.h:87
bool isDynamic() const noexcept
Returns whether the small array uses its dynamic storage.
Definition SmallArray.h:1276
void resize(size_t n)
Changing the size of the array.
Definition SmallArray.h:827
T & Reference
Reference to a non-constant array element.
Definition SmallArray.h:90
Reference at(size_t index)
Checked access to the array elements.
Definition SmallArray.h:486
Iterator begin() noexcept
Returns an iterator to the first element of the small array.
Definition SmallArray.h:565
T * end_
Pointer to the end of the currently used storage.
Definition SmallArray.h:200
Iterator end() noexcept
Returns an iterator just past the last element of the small array.
Definition SmallArray.h:613
void swap(SmallArray &sa) noexcept(IsNothrowMoveConstructible_v< T >)
Swapping the contents of two small arrays.
Definition SmallArray.h:1204
const T * ConstIterator
Iterator over constant elements.
Definition SmallArray.h:93
bool empty() const noexcept
Returns whether the array is empty.
Definition SmallArray.h:752
T * Iterator
Iterator over non-constant elements.
Definition SmallArray.h:92
void clear()
Clearing the array.
Definition SmallArray.h:799
const T & ConstReference
Reference to a constant array element.
Definition SmallArray.h:91
size_t size() const noexcept
Returns the current size/dimension of the small array.
Definition SmallArray.h:767
Iterator erase(Iterator pos)
Erasing an element from the small array.
Definition SmallArray.h:1152
SmallArray(const A &alloc=A())
The (default) constructor for SmallArray.
Definition SmallArray.h:231
~SmallArray()
The destructor for SmallArray.
Definition SmallArray.h:410
Initializer list type of the Blaze library.
void destroy(ForwardIt first, ForwardIt last)
Destroys the given range of objects .
Definition Destroy.h:67
void uninitialized_default_construct(ForwardIt first, ForwardIt last)
Default constructs elements in the given range.
Definition UninitializedDefaultConstruct.h:69
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:72
void destroy_at(T *p) noexcept
Destroys the object at the given address.
Definition DestroyAt.h:57
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition Const.h:79
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:1375
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition DiagonalMatrix.h:225
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
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
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition Matrix.h:960
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:628
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:562
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:584
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition Matrix.h:518
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition Assert.h:117
constexpr bool IsNothrowMoveConstructible_v
Auxiliary variable template for the IsNothrowMoveConstructible type trait.
Definition IsConstructible.h:427
void deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition Memory.h:230
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition Exception.h:331
T * allocate(size_t size)
Aligned array allocation for built-in data types.
Definition Memory.h:158
Definition of the nested auxiliary struct Uninitialized.
Definition SmallArray.h:176
Header file for exception macros.
Header file for the initializer_list template.
Header file for basic type definitions.
Header file for the generic max algorithm.