Loading src/TNL/Containers/Algorithms/ArrayOperations.h +22 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,14 @@ struct ArrayOperations< void > const SourceElement* source, const Index size ); template< typename DestinationElement, typename Index, typename SourceIterator > static void copyFromIterator( DestinationElement* destination, Index destinationSize, SourceIterator first, SourceIterator last ); template< typename Element1, typename Element2, typename Index > Loading @@ -55,6 +63,20 @@ struct ArrayOperations< void > static bool compare( const Element1* destination, const Element2* source, const Index size ); template< typename Element, typename Index > __cuda_callable__ static bool containsValue( const Element* data, const Index size, const Element& value ); template< typename Element, typename Index > __cuda_callable__ static bool containsOnlyValue( const Element* data, const Index size, const Element& value ); }; template<> Loading src/TNL/Containers/Algorithms/ArrayOperationsStatic.hpp +55 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,23 @@ copy( DestinationElement* destination, destination[ i ] = source[ i ]; } template< typename DestinationElement, typename Index, typename SourceIterator > void ArrayOperations< void >:: copyFromIterator( DestinationElement* destination, Index destinationSize, SourceIterator first, SourceIterator last ) { Index i = 0; while( i < destinationSize && first != last ) destination[ i++ ] = *first++; if( first != last ) throw std::length_error( "Source iterator is larger than the destination array." ); } template< typename Element1, typename Element2, typename Index > Loading @@ -77,6 +94,44 @@ compare( const Element1* destination, return true; } template< typename Element, typename Index > __cuda_callable__ bool ArrayOperations< void >:: containsValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); for( Index i = 0; i < size; i++ ) if( data[ i ] == value ) return true; return false; } template< typename Element, typename Index > __cuda_callable__ bool ArrayOperations< void >:: containsOnlyValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); for( Index i = 0; i < size; i++ ) if( ! ( data[ i ] == value ) ) return false; return true; } } // namespace Algorithms } // namespace Containers } // namespace TNL Loading
src/TNL/Containers/Algorithms/ArrayOperations.h +22 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,14 @@ struct ArrayOperations< void > const SourceElement* source, const Index size ); template< typename DestinationElement, typename Index, typename SourceIterator > static void copyFromIterator( DestinationElement* destination, Index destinationSize, SourceIterator first, SourceIterator last ); template< typename Element1, typename Element2, typename Index > Loading @@ -55,6 +63,20 @@ struct ArrayOperations< void > static bool compare( const Element1* destination, const Element2* source, const Index size ); template< typename Element, typename Index > __cuda_callable__ static bool containsValue( const Element* data, const Index size, const Element& value ); template< typename Element, typename Index > __cuda_callable__ static bool containsOnlyValue( const Element* data, const Index size, const Element& value ); }; template<> Loading
src/TNL/Containers/Algorithms/ArrayOperationsStatic.hpp +55 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,23 @@ copy( DestinationElement* destination, destination[ i ] = source[ i ]; } template< typename DestinationElement, typename Index, typename SourceIterator > void ArrayOperations< void >:: copyFromIterator( DestinationElement* destination, Index destinationSize, SourceIterator first, SourceIterator last ) { Index i = 0; while( i < destinationSize && first != last ) destination[ i++ ] = *first++; if( first != last ) throw std::length_error( "Source iterator is larger than the destination array." ); } template< typename Element1, typename Element2, typename Index > Loading @@ -77,6 +94,44 @@ compare( const Element1* destination, return true; } template< typename Element, typename Index > __cuda_callable__ bool ArrayOperations< void >:: containsValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); for( Index i = 0; i < size; i++ ) if( data[ i ] == value ) return true; return false; } template< typename Element, typename Index > __cuda_callable__ bool ArrayOperations< void >:: containsOnlyValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); for( Index i = 0; i < size; i++ ) if( ! ( data[ i ] == value ) ) return false; return true; } } // namespace Algorithms } // namespace Containers } // namespace TNL