Skip to content
Snippets Groups Projects
EllpackIndexMultimapValues_impl.h 6.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • /***************************************************************************
    
                              EllpackIndexMultimapValues_impl.h  -  description
    
                                 -------------------
        begin                : Sep 10, 2015
        copyright            : (C) 2015 by Tomas Oberhuber et al.
        email                : tomas.oberhuber@fjfi.cvut.cz
     ***************************************************************************/
    
    
    /* See Copyright Notice in tnl/Copyright */
    
    #pragma once
    
    #include "EllpackIndexMultimapValues.h"
    
    #include <TNL/Assert.h>
    
    
    namespace TNL {
     
    
    template< typename Index,
    
              typename Device,
              typename LocalIndex >
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    EllpackIndexMultimapValues()
    
    : values( nullptr ), valuesCount( nullptr ), allocatedSize( 0 )
    
    template< typename Index,
    
              typename Device,
              typename LocalIndex >
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    EllpackIndexMultimapValues( EllpackIndexMultimapValues&& other )
    
    : values( other.values ), valuesCount( other.valuesCount ), allocatedSize( other.allocatedSize )
    
       other.allocatedSize = 0;
    }
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    EllpackIndexMultimapValues< Index, Device, LocalIndex >&
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    operator=( const EllpackIndexMultimapValues& other )
    
    {
       Assert( this->getSize() == other.getSize(), );
       if( this->values != other.values ) {
          for( LocalIndexType i = 0; i < this->getSize(); i++ )
             this->setValue( i, other[ i ] );
       }
       return *this;
    }
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    EllpackIndexMultimapValues< Index, Device, LocalIndex >&
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    operator=( EllpackIndexMultimapValues&& other )
    
       this->allocatedSize = other.allocatedSize;
       other.values = nullptr;
    
       other.allocatedSize = 0;
       return *this;
    }
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    void
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    bind( const EllpackIndexMultimapValues& other )
    
       this->allocatedSize = other.allocatedSize;
    }
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    EllpackIndexMultimapValues( IndexType* values,
    
                                const IndexType& input,
    
       this->values = &values[ input * allocatedSize ];
       this->valuesCount = &valuesCounts[ input ];
    
       Assert( *(this->valuesCount) <= allocatedSize, );
    
    }
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    bool
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    setSize( const LocalIndexType& size )
    {
    
       if( ! this->valuesCount || size > this->allocatedSize )
    
       return true;
    }
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    LocalIndex
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    getSize() const
    
    template< typename Index,
    
              typename Device,
              typename LocalIndex >
    LocalIndex
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    template< typename Index,
    
              typename Device,
              typename LocalIndex >
    
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    setValue( const LocalIndexType& portIndex,
              const IndexType& value )
    
                  std::cerr << " portIndex = " << portIndex
    
                            << std::endl );
    
    template< typename Index,
    
              typename Device,
              typename LocalIndex >
    
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    getValue( const LocalIndexType& portIndex ) const
    
                  std::cerr << " portIndex = " << portIndex
    
                            << std::endl );
    
    template< typename Index,
    
              typename Device,
              typename LocalIndex >
    
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    operator[]( const LocalIndexType& portIndex )
    
                  std::cerr << " portIndex = " << portIndex
    
                            << std::endl );
    
    template< typename Index,
    
              typename Device,
              typename LocalIndex >
    
    const Index&
    
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    operator[]( const LocalIndexType& portIndex ) const
    
                  std::cerr << " portIndex = " << portIndex
    
                            << std::endl );
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    bool
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    operator==( const EllpackIndexMultimapValues& other ) const
    
    {
       if( this->getSize() != other.getSize() )
          return false;
       for( LocalIndexType i = 0; i < this->getSize(); i++ )
          if( this->operator[]( i ) != other[ i ] )
             return false;
       return true;
    }
    
    
    template< typename Index,
              typename Device,
              typename LocalIndex >
    bool
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
    operator!=( const EllpackIndexMultimapValues& other ) const
    
              typename Device,
              typename LocalIndex >
    
    EllpackIndexMultimapValues< Index, Device, LocalIndex >::
    
       str << "[ ";
       if( this->getSize() > 0 )
    
          str << this->getValue( 0 );
    
          for( typename std::remove_const< Index >::type i = 1; i < this->getSize(); i++ )
    
             str << ", " << this->getValue( i );
    
              typename Device,
              typename LocalIndex >
    std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex >& ports )
    
    } // namespace TNL