Loading src/TNL/Containers/Array.h +9 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,15 @@ class Array */ explicit Array( const IndexType& size, const AllocatorType& allocator = AllocatorType() ); /** * \brief Constructs an array with given size and value. * * \param size The number of array elements to be allocated. * \param value The value all elements will be set to. * \param allocator The allocator to be associated with this array. */ explicit Array( const IndexType& size, const Value& value, const AllocatorType& allocator = AllocatorType() ); /** * \brief Constructs an array with given size and copies data from given * pointer. Loading src/TNL/Containers/Array.hpp +12 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,18 @@ Array( const IndexType& size, const AllocatorType& allocator ) this->setSize( size ); } template< typename Value, typename Device, typename Index, typename Allocator > Array< Value, Device, Index, Allocator >:: Array( const IndexType& size, const Value& value, const AllocatorType& allocator ) : allocator( allocator ) { this->setSize( size ); ( *this ) = value; } template< typename Value, typename Device, typename Index, Loading src/UnitTests/Containers/ArrayTest.h +5 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,11 @@ TYPED_TEST( ArrayTest, constructors ) v = 0; EXPECT_EQ( v.getSize(), 10 ); ArrayType vv( 10, 4 ); EXPECT_EQ( vv.getSize(), 10 ); for( int i = 0; i < 10; i++ ) EXPECT_EQ( vv.getElement( i ), 4 ); // deep copy ArrayType w( v ); EXPECT_NE( w.getData(), v.getData() ); Loading Loading
src/TNL/Containers/Array.h +9 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,15 @@ class Array */ explicit Array( const IndexType& size, const AllocatorType& allocator = AllocatorType() ); /** * \brief Constructs an array with given size and value. * * \param size The number of array elements to be allocated. * \param value The value all elements will be set to. * \param allocator The allocator to be associated with this array. */ explicit Array( const IndexType& size, const Value& value, const AllocatorType& allocator = AllocatorType() ); /** * \brief Constructs an array with given size and copies data from given * pointer. Loading
src/TNL/Containers/Array.hpp +12 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,18 @@ Array( const IndexType& size, const AllocatorType& allocator ) this->setSize( size ); } template< typename Value, typename Device, typename Index, typename Allocator > Array< Value, Device, Index, Allocator >:: Array( const IndexType& size, const Value& value, const AllocatorType& allocator ) : allocator( allocator ) { this->setSize( size ); ( *this ) = value; } template< typename Value, typename Device, typename Index, Loading
src/UnitTests/Containers/ArrayTest.h +5 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,11 @@ TYPED_TEST( ArrayTest, constructors ) v = 0; EXPECT_EQ( v.getSize(), 10 ); ArrayType vv( 10, 4 ); EXPECT_EQ( vv.getSize(), 10 ); for( int i = 0; i < 10; i++ ) EXPECT_EQ( vv.getElement( i ), 4 ); // deep copy ArrayType w( v ); EXPECT_NE( w.getData(), v.getData() ); Loading