Commit a577ef19 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixing Array and ArrayView interface.

parent 1fd324cf
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -479,6 +479,18 @@ class Array
                     const Index begin = 0,
                     Index end = -1 );

      /**
       * \brief Sets the array elements using given lambda function.
       *
       * Sets all the array values to \e v.
       *
       * \param v Reference to a value.
       */
      template< typename Function >
      void evaluate( const Function& f,
                     const Index begin = 0,
                     Index end = -1 );

      /**
       * \brief Checks if there is an element with value \e v.
       *
+12 −0
Original line number Diff line number Diff line
@@ -612,6 +612,18 @@ void Array< Value, Device, Index >::setValue( const ValueType& e,
   Algorithms::ArrayOperations< Device >::setMemory( &this->getData()[ begin ], e, end - begin );
}

template< typename Value,
          typename Device,
          typename Index >
   template< typename Function >
void Array< Value, Device, Index >::evaluate( const Function& f,
                                              const Index begin,
                                              Index end )
{
   TNL_ASSERT_TRUE( this->getData(), "Attempted to set a value of an empty array." );
   this->getView().evaluate( f, begin, end );
}

template< typename Value,
          typename Device,
          typename Index >
+3 −1
Original line number Diff line number Diff line
@@ -367,7 +367,9 @@ public:
    *
    * \param v Reference to a value.
    */
   void setValue( Value value );
   void setValue( Value value,
                  const Index begin = 0,
                  Index end = -1 );

   /**
    * \brief Sets the array elements using given lambda function.
+4 −2
Original line number Diff line number Diff line
@@ -299,10 +299,12 @@ template< typename Value,
          typename Index >
void
ArrayView< Value, Device, Index >::
setValue( Value value )
setValue( Value value, const Index begin, Index end )
{
   TNL_ASSERT_GT( size, 0, "Attempted to set value to an empty array view." );
   Algorithms::ArrayOperations< Device >::setMemory( getData(), value, getSize() );
   if( end == -1 )
      end = this->getSize();
   Algorithms::ArrayOperations< Device >::setMemory( &getData()[ begin ], value, end - begin );
}

template< typename Value,