Commit 6412bea4 authored by Nina Džugasová's avatar Nina Džugasová
Browse files

Added to Array documentation.

parent 5b92a5ec
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -37,5 +37,11 @@ target_link_libraries( MathExample tnl )
ADD_EXECUTABLE( StringExample StringExample.cpp )
target_link_libraries( StringExample tnl )

ADD_EXECUTABLE( StringExampleGetSize StringExampleGetSize.cpp )
target_link_libraries( StringExampleGetSize tnl )

ADD_EXECUTABLE( StringExampleGetAllocatedSize StringExampleGetAllocatedSize.cpp )
target_link_libraries( StringExampleGetAllocatedSize tnl )

ADD_EXECUTABLE( TimerExample TimerExample.cpp )
target_link_libraries( TimerExample tnl )
 No newline at end of file
+65 −19
Original line number Diff line number Diff line
@@ -66,16 +66,19 @@ class Array : public Object
             const IndexType& begin = 0,
             const IndexType& size = 0 );

      /** \brief Returns type of string - String. */
      /** \brief Returns type of array value, device type and the type of index. */
      static String getType();

      /** \brief Returns type of array value, device type and the type of index. */
      virtual String getTypeVirtual() const;

      /** \brief Returns (host) type of array value, device type and the type of index. */
      static String getSerializationType();

      /** \brief Returns (host) type of array value, device type and the type of index. */
      virtual String getSerializationTypeVirtual() const;

      /****
      /**
       * \brief Method for setting the size of an array.
       *
       * If the array shares data with other arrays these data are released.
@@ -86,11 +89,13 @@ class Array : public Object
       */
      void setSize( Index size );

      /** \brief Method for getting the size of an array. */
      __cuda_callable__ Index getSize() const;

      /**
       * \brief Assigns features of the existing \e array to the given array.
       *
       * Sets the same size as the size of existing \e array.
       * \tparam ArrayT Type of array.
       * \param array Existing array.
       */
@@ -108,6 +113,13 @@ class Array : public Object
      template< int Size >
      void bind( StaticArray< Size, Value >& array );

      /** 
       * \brief Swaps all features of given array with existing \e array.
       *
       * Swaps sizes, all values (data), allocated memory and references of given
       * array with existing array.
       * \param array Existing array, which features are swaped with given array.
       */
      void swap( Array& array );

      /**
@@ -117,12 +129,18 @@ class Array : public Object
       */
      void reset();

      /**
       * \brief Method for getting the data from given array with constant poiner.
       */
      __cuda_callable__ const Value* getData() const;

      /**
       * \brief Method for getting the data from given array.
       */
      __cuda_callable__ Value* getData();

      /**
       * \brief Sets the value \e x of the array element at position \e i.
       * \brief Assignes the value \e x to the array element at position \e i.
       *
       * \param i Index position.
       * \param x New value of an element.
@@ -130,14 +148,24 @@ class Array : public Object
      void setElement( const Index& i, const Value& x );

      /**
       * \brief Accesses specified element at the position \e i.
       * \brief Accesses specified element at the position \e i and returns its value.
       *
       * \param i Index position of an element.
       */
      Value getElement( const Index& i ) const;

      /**
       * \brief Accesses specified element at the position \e i and returns a reference to its value.
       *
       * \param i Index position of an element.
       */
      __cuda_callable__ inline Value& operator[] ( const Index& i );

      /**
       * \brief Accesses specified element at the position \e i and returns a (constant?) reference to its value.
       *
       * \param i Index position of an element.
       */
      __cuda_callable__ inline const Value& operator[] ( const Index& i ) const;

      Array& operator = ( const Array& array );
@@ -151,30 +179,43 @@ class Array : public Object
      template< typename ArrayT >
      bool operator != ( const ArrayT& array ) const;

      /**
       * \brief
       *
       * \param v Reference to a value.
       */
      void setValue( const Value& v );

      /**
       * Checks if there is an element with value v in this array
       * \brief Checks if there is an element with value \e v in given array.
       *
       * \param v Reference to a value.
       */
      bool containsValue( const Value& v ) const;

      /**
       * Checks if all elements in this array have the same value v
       * \brief Checks if all elements in given array have the same value \e v.
       *
       * \param v Reference to a value.
       */
      bool containsOnlyValue( const Value& v ) const;

      /**
       * Returns true if non-zero size is set.
       * \brief Returns true if non-zero size is set.
       */
      operator bool() const;

      /**
       * \brief Method for saving the object to a \e file as a binary data.
       *
       * \param file Reference to a file.
       */
      bool save( File& file ) const;

      /**
       * Method for loading the object from a file as a binary data.
       *
       * \param file Reference to a file.
       */
      bool load( File& file );

@@ -194,31 +235,36 @@ class Array : public Object

      using Object::boundLoad;

      /** \brief Basic destructor. */
      ~Array();

   protected:

      /** \brief Method for releasing array data. */
      void releaseData() const;

      //!Number of elements in array
      /** \brief Number of elements in array. */
      mutable Index size;

      //! Pointer to data
      /** \brief Pointer to data. */
      mutable Value* data;

      /****
       * Pointer to the originally allocated data. They might differ if one
       * long array is partitioned into more shorter arrays. Each of them
       * must know the pointer on allocated data because the last one must
       * deallocate the array. If outer data (not allocated by TNL) are bind
       * then this pointer is zero since no deallocation is necessary.
      /**
       * \brief Pointer to the originally allocated data.
       *
       * They might differ if one long array is partitioned into more shorter
       * arrays. Each of them must know the pointer on allocated data because 
       * the last one must deallocate the array. If outer data (not allocated
       * by TNL) are bind then this pointer is zero since no deallocation is
       * necessary.
       */
      mutable Value* allocationPointer;

      /****
       * Counter of objects sharing this array or some parts of it. The reference counter is
       * allocated after first sharing of the data between more arrays. This is to avoid
       * unnecessary dynamic memory allocation.
      /**
       * \brief Counter of objects sharing this array or some parts of it.
       *
       * The reference counter is allocated after first sharing of the data
       * between more arrays. This is to avoid unnecessary dynamic memory allocation.
       */
      mutable int* referenceCounter;
};