diff --git a/Documentation/Examples/StringExample.cpp b/Documentation/Examples/StringExample.cpp index 609e2a26981362a663f2a92e6a82c6f86a94e41c..a86182d6574cde1d8ee2e65f2d0a14d251c837a7 100644 --- a/Documentation/Examples/StringExample.cpp +++ b/Documentation/Examples/StringExample.cpp @@ -1,6 +1,5 @@ #include <iostream> #include <TNL/String.h> -#include <TNL/Containers/List.h> #include <TNL/File.h> using namespace TNL; diff --git a/Documentation/Tutorials/Vectors/Reduction.cpp b/Documentation/Tutorials/Vectors/Reduction.cpp index 1d76d8d0405d815d01b9f5ddc155694d76e64067..33768b07f456e38e14b8bfadd7466233075de47f 100644 --- a/Documentation/Tutorials/Vectors/Reduction.cpp +++ b/Documentation/Tutorials/Vectors/Reduction.cpp @@ -24,7 +24,6 @@ void expressions() b.evaluate( [] __cuda_callable__ ( int i )->RealType { return i - 5.0; } ); c = -5; - int arg; std::cout << "a = " << a << std::endl; std::cout << "b = " << b << std::endl; std::cout << "c = " << c << std::endl; diff --git a/src/Examples/CMakeLists.txt b/src/Examples/CMakeLists.txt index 4038095719828aed5da45f9b62da30ac120d74cd..493f537d11ef6b6c54f42d476aca4d08cedf17cb 100644 --- a/src/Examples/CMakeLists.txt +++ b/src/Examples/CMakeLists.txt @@ -12,6 +12,5 @@ add_subdirectory( flow-vl ) ADD_EXECUTABLE( ConfigDescriptionExample ConfigDescriptionExample.cpp ) -ADD_EXECUTABLE( ListExample ListExample.cpp ) ADD_EXECUTABLE( LoggerExample LoggerExample.cpp ) ADD_EXECUTABLE( MathExample MathExample.cpp ) diff --git a/src/Examples/ListExample.cpp b/src/Examples/ListExample.cpp deleted file mode 100644 index 7196dc7594689bca4395976f43b23c8b12d42eb5..0000000000000000000000000000000000000000 --- a/src/Examples/ListExample.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include <iostream> -#include <TNL/Config/ConfigDescription.h> -#include <TNL/Containers/List.h> -#include <TNL/Containers/Array.h> - -using namespace TNL; -using namespace std; - -int main() -{ - Containers::List< int > lst; - lst.isEmpty(); - - lst.Append(1); - lst.Append(3); - - lst.isEmpty(); - lst.getSize(); - - lst.Insert(2,1); - - Containers::Array<int> array; - lst.toArray(array); -} \ No newline at end of file diff --git a/src/TNL/Containers/List.h b/src/TNL/Containers/List.h deleted file mode 100644 index 3558a1b2c3ddb4054dfaddb6566d8ae8823e5507..0000000000000000000000000000000000000000 --- a/src/TNL/Containers/List.h +++ /dev/null @@ -1,226 +0,0 @@ -/*************************************************************************** - List.h - description - ------------------- - begin : Sat, 10 Apr 2004 15:58:51 +0100 - copyright : (C) 2004 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include <iostream> - -#include <TNL/Assert.h> -#include <TNL/File.h> -#include <TNL/String.h> -#include <TNL/TypeInfo.h> - -namespace TNL { -namespace Containers { - -template< class T > class ListDataElement; - -/// \brief Template for double linked lists -/*! To acces elements in the list one can use method getSize() and - operator[](). To add elements there are methods Append(), - Prepend() and Insert() to insert an element at given - position. To erase particular element there is method - Erase() taking the element position. To erase all elements - there is method reset(). There are also alternatives DeepErase() - and DeepEraseAll() to free dynamicaly allocated data inside the - data elements. - The list stores pointer to last accesed element so if one goes - seqeuntialy through the list there is no inefficiency. The - accesing algorithm is also able to deside whether to start from - the last accesed position or from the begining resp. from the end - of the list. So with common use one does not need to worry about - efficiency :-) - */ -template< class T > class List -{ - public: - typedef T ValueType; - - /// \brief Basic constructor. - /// - /// Constructs an empty list. - List(); - - /// \brief Copy constructor. - /// - /// Construct a copy of \e list. - /// \param list Name of another list. - List( const List& list ); - - /// \brief Destructor. - /// - /// Destroys the list. References to the values in the list become invalid. - ~List(); - - /// Returns \e true if the list contains no items, otherwise returns \e false. - bool isEmpty() const; - - /// Returns number of items in the list. - int getSize() const; - - /// Indexing operator. - T& operator[] ( const int& ind ); - - /// Indexing operator for constant instances. - const T& operator[] ( const int& ind ) const; - - const List& operator = ( const List& lst ); - - bool operator == ( const List& lst ) const; - - bool operator != ( const List& lst ) const; - - /// \brief Appends new data element. - /// - /// Inserts \e data at the end of the list. - bool Append( const T& data ); - - /// \brief Prepends new data element. - /// - /// Inserts \e data at the beginning of the list. - bool Prepend( const T& data ); - - /// \brief Inserts new data element at given position. - /// - /// Inserts \e data at index position \e ind in the list. - bool Insert( const T& data, const int& ind ); - - /// Appends copy of another list. - /// - /// \param lst Name of another list. - bool AppendList( const List< T >& lst ); - - /// Prepends copy of another list. - /// - /// \param lst Name of another list. - bool PrependList( const List< T >& lst ); - - /// Transforms list to an \e array. - template< typename Array > - void toArray( Array& array ); - - /*** - * \brief Checks if there is an element with value \e v in given array. - * - * \param v Reference to a value. - */ - bool containsValue( const T& v ) const; - - /// Erases data element at given position. - /// - /// \param ind Index of the data element one chooses to remove. - void Erase( const int& ind ); - - /// Erases data element with contained data at given position. - /// - /// \param ind Index of the data element one chooses to remove. - void DeepErase( const int& ind ); - - /// Erases all data elements. - void reset(); - - /// \brief Erases all data elements with contained data. - /// - /// Frees dynamicaly allocated data inside the data elements - void DeepEraseAll(); - - /// Saves the list in binary format. - /// - /// \param file Name of file. - bool Save( File& file ) const; - - /// Saves the list in binary format using method save of type T. - /// - /// \param file Name of file. - bool DeepSave( File& file ) const; - - /// Loads the list from file. - /// - /// \param file Name of file. - bool Load( File& file ); - - /// Loads the list from file using method Load of the type T. - /// - /// \param file Name of file. - bool DeepLoad( File& file ); - - protected: - /// Pointer to the first element. - ListDataElement< T >* first; - - /// Pointer to the last element. - /*! We use pointer to last element while adding new element to keep order of elements - */ - ListDataElement< T >* last; - - /// List size. - int size; - - /// Iterator. - mutable ListDataElement< T >* iterator; - - /// Iterator index. - mutable int index; -}; - -template< typename T > std::ostream& operator << ( std::ostream& str, const List< T >& list ); - -//! Data element for List and mStack -template< class T > class ListDataElement -{ - //! Main data - T data; - - //! Pointer to the next element - ListDataElement< T >* next; - - //! Pointer to the previous element - ListDataElement< T >* previous; - - public: - //! Basic constructor - ListDataElement() - : next( 0 ), - previous( 0 ){}; - - //! Constructor with given data and possibly pointer to next element - ListDataElement( const T& dt, - ListDataElement< T >* prv = 0, - ListDataElement< T >* nxt = 0 ) - : data( dt ), - next( nxt ), - previous( prv ){}; - - //! Destructor - ~ListDataElement(){}; - - //! Return data for non-const instances - T& Data() { return data; }; - - //! Return data for const instances - const T& Data() const { return data; }; - - //! Return pointer to the next element for non-const instances - ListDataElement< T >*& Next() { return next; }; - - //! Return pointer to the next element for const instances - const ListDataElement< T >* Next() const { return next; }; - - //! Return pointer to the previous element for non-const instances - ListDataElement< T >*& Previous() { return previous; }; - - //! Return pointer to the previous element for const instances - const ListDataElement< T >* Previous() const { return previous; }; -}; - -} // namespace Containers -} // namespace TNL - -#include <TNL/Containers/List_impl.h> diff --git a/src/TNL/Containers/List_impl.h b/src/TNL/Containers/List_impl.h deleted file mode 100644 index 3068de31568f18c8c6ea2b2b6e0951204e6dfa7f..0000000000000000000000000000000000000000 --- a/src/TNL/Containers/List_impl.h +++ /dev/null @@ -1,346 +0,0 @@ -/*************************************************************************** - List_impl.h - description - ------------------- - begin : Mar, 5 Apr 2016 12:46 PM - copyright : (C) 2016 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include <TNL/Containers/List.h> -#include <TNL/Math.h> - -namespace TNL { -namespace Containers { - -template< typename T > -List< T >::List() - : first( 0 ), last( 0 ), size( 0 ), iterator( 0 ), index( 0 ) -{ -} - -template< typename T > -List< T >::List( const List& list ) - : first( 0 ), last( 0 ), size( 0 ), iterator( 0 ), index( 0 ) -{ - AppendList( list ); -} - -template< typename T > -List< T >::~List() -{ - reset(); -} - -template< typename T > -bool List< T >::isEmpty() const -{ - return ! size; -} - -template< typename T > -int List< T >::getSize() const -{ - return size; -} - -template< typename T > -T& List< T >::operator[]( const int& ind ) -{ - TNL_ASSERT( ind < size, ); - int iter_dist = TNL::abs( index - ind ); - if( ! iterator || - iter_dist > ind || - iter_dist > size - ind ) - { - if( ind < size - ind ) - { - //cout << "Setting curent index to 0." << std::endl; - index = 0; - iterator = first; - } - else - { - //cout << "Setting curent index to size - 1." << std::endl; - index = size - 1; - iterator = last; - } - } - while( index != ind ) - { - //cout << " current index = " << index - // << " index = " << ind << std::endl; - if( ind < index ) - { - iterator = iterator -> Previous(); - index --; - } - else - { - iterator = iterator -> Next(); - index ++; - } - TNL_ASSERT( iterator, ); - } - return iterator -> Data(); -}; - -template< typename T > -const T& List< T >::operator[]( const int& ind ) const -{ - return const_cast< List< T >* >( this ) -> operator[]( ind ); -} - -template< typename T > -const List< T >& List< T >::operator = ( const List& lst ) -{ - AppendList( lst ); - return( *this ); -} - -template< typename T > -bool List< T >::operator == ( const List& lst ) const -{ - if( this->getSize() != lst.getSize() ) - return false; - for( int i = 0; i < this->getSize(); i++ ) - if( (*this)[ i ] != lst[ i ] ) - return false; - return true; -} - -template< typename T > -bool List< T >::operator != ( const List& lst ) const -{ - return ! operator==( lst ); -} - -template< typename T > -bool List< T >::Append( const T& data ) -{ - if( ! first ) - { - TNL_ASSERT( ! last, ); - first = last = new ListDataElement< T >( data ); - } - else - { - ListDataElement< T >* new_element = new ListDataElement< T >( data, last, 0 ); - TNL_ASSERT( last, ); - last = last -> Next() = new_element; - } - size ++; - return true; -}; - -template< typename T > -bool List< T >::Prepend( const T& data ) -{ - if( ! first ) - { - TNL_ASSERT( ! last, ); - first = last = new ListDataElement< T >( data ); - } - else - { - ListDataElement< T >* new_element = new ListDataElement< T >( data, 0, first ); - first = first -> Previous() = new_element; - } - size ++; - index ++; - return true; -}; - -template< typename T > -bool List< T >::Insert( const T& data, const int& ind ) -{ - TNL_ASSERT( ind <= size || ! size, ); - if( ind == 0 ) return Prepend( data ); - if( ind == size ) return Append( data ); - operator[]( ind ); - ListDataElement< T >* new_el = - new ListDataElement< T >( data, - iterator -> Previous(), - iterator ); - iterator -> Previous() -> Next() = new_el; - iterator -> Previous() = new_el; - iterator = new_el; - size ++; - return true; -}; - -template< typename T > -bool List< T >::AppendList( const List< T >& lst ) -{ - int i; - for( i = 0; i < lst. getSize(); i ++ ) - { - if( ! Append( lst[ i ] ) ) return false; - } - return true; -}; - -template< typename T > -bool List< T >::PrependList( const List< T >& lst ) - -{ - int i; - for( i = lst. getSize(); i > 0; i -- ) - if( ! Prepend( lst[ i - 1 ] ) ) return false; - return true; -}; - -template< typename T > - template< typename Array > -void List< T >::toArray( Array& array ) -{ - array.setSize( this->getSize() ); - for( int i = 0; i < this->getSize(); i++ ) - array[ i ] = ( *this )[ i ]; -} -template< typename T > -bool List< T >::containsValue( const T& v ) const -{ - for( int i = 0; i < this->getSize(); i++ ) - if( ( *this )[ i ] == v ) - return true; - return false; -} - -template< typename T > -void List< T >::Erase( const int& ind ) -{ - operator[]( ind ); - ListDataElement< T >* tmp_it = iterator; - if( iterator -> Next() ) - iterator -> Next() -> Previous() = iterator -> Previous(); - if( iterator -> Previous() ) - iterator -> Previous() -> Next() = iterator -> Next(); - if( iterator -> Next() ) iterator = iterator -> Next(); - else - { - iterator = iterator -> Previous(); - index --; - } - if( first == tmp_it ) first = iterator; - if( last == tmp_it ) last = iterator; - delete tmp_it; - size --; -}; - -template< typename T > -void List< T >::DeepErase( const int& ind ) -{ - operator[]( ind ); - delete iterator -> Data(); - Erase( ind ); -}; - -template< typename T > -void List< T >::reset() -{ - iterator = first; - ListDataElement< T >* tmp_it; - while( iterator ) - { - TNL_ASSERT( iterator, ); - tmp_it = iterator; - iterator = iterator -> Next(); - delete tmp_it; - } - first = last = 0; - size = 0; -}; - -template< typename T > -void List< T >::DeepEraseAll() -{ - iterator = first; - ListDataElement< T >* tmp_it; - int i( 0 ); - while( iterator ) - { - tmp_it = iterator; - iterator = iterator -> Next(); - delete tmp_it -> Data(); - delete tmp_it; - i++; - } - first = last = 0; - size = 0; -}; - -template< typename T > -bool List< T >::Save( File& file ) const -{ - file.save( &size ); - for( int i = 0; i < size; i ++ ) - if( ! file. save( &operator[]( i ), 1 ) ) - return false; - return true; -} - -template< typename T > -bool List< T >::DeepSave( File& file ) const -{ - file.save( &size ); - for( int i = 0; i < size; i ++ ) - if( ! operator[]( i ). save( file ) ) return false; - return true; -} - -template< typename T > -bool List< T >::Load( File& file ) -{ - reset(); - int _size; - file.load( &_size, 1 ); - if( _size < 0 ) - { - std::cerr << "The curve size is negative." << std::endl; - return false; - } - T t; - for( int i = 0; i < _size; i ++ ) - { - if( ! file.load( &t, 1 ) ) - return false; - Append( t ); - } - return true; -}; - -template< typename T > -bool List< T >::DeepLoad( File& file ) -{ - reset(); - int _size; - file.load( &_size ); - if( _size < 0 ) - { - std::cerr << "The list size is negative." << std::endl; - return false; - } - for( int i = 0; i < _size; i ++ ) - { - T t; - if( ! t. load( file ) ) return false; - Append( t ); - } - return true; -}; - -template< typename T > -std::ostream& operator << ( std::ostream& str, const List< T >& list ) -{ - int i, size( list. getSize() ); - for( i = 0; i < size; i ++ ) - str << "Item " << i << ":" << list[ i ] << std::endl; - return str; -}; - -} // namespace Containers -} // namespace TNL diff --git a/src/TNL/Images/DicomSeries.h b/src/TNL/Images/DicomSeries.h index 50355bc34695cafcabf2a1d6999ef5791a0dec0a..b5aa77a57d3a2c3322cc7d79b6a31ff7c22e68d4 100644 --- a/src/TNL/Images/DicomSeries.h +++ b/src/TNL/Images/DicomSeries.h @@ -14,8 +14,9 @@ #pragma once +#include <list> + #include <TNL/Containers/Array.h> -#include <TNL/Containers/List.h> #include <TNL/String.h> #include <TNL/TypeInfo.h> #include <TNL/Images//Image.h> @@ -102,7 +103,7 @@ class DicomSeries : public Image< int > bool loadImage( const String& filePath, int number ); - Containers::List< String > fileList; + std::list< String > fileList; Containers::Array<DicomHeader *,Devices::Host,int> dicomSeriesHeaders; diff --git a/src/TNL/Images/DicomSeries_impl.h b/src/TNL/Images/DicomSeries_impl.h index 350bf384bbadae0eeb1045e1553010953f6a9390..533808b0d53559aee3c56fbd268194fafc7ecd34 100644 --- a/src/TNL/Images/DicomSeries_impl.h +++ b/src/TNL/Images/DicomSeries_impl.h @@ -155,22 +155,22 @@ inline bool DicomSeries::retrieveFileList( const String& filePath) String fileNamePrefix(fileName.getString(), 0, fileName.getLength() - separatorPosition); struct dirent **dirp; - Containers::List<String > files; + std::list< String > files; //scan and sort directory int ndirs = scandir(directoryPath.getString(), &dirp, filter, alphasort); for(int i = 0 ; i < ndirs; ++i) { - files.Append( String((char *)dirp[i]->d_name)); + files.push_back( String((char *)dirp[i]->d_name) ); delete dirp[i]; } - for (int i = 0; i < files.getSize(); i++) + for (auto& file : files) { //check if file prefix contained - if (strstr(files[ i ].getString(), fileNamePrefix.getString())) + if (strstr(file.getString(), fileNamePrefix.getString())) { - fileList.Append( directoryPath + files[ i ] ); + fileList.push_back( directoryPath + file ); } } } @@ -182,7 +182,7 @@ inline bool DicomSeries::loadImage( const String& filePath, int number) #ifdef HAVE_DCMTK_H //load header DicomHeader *header = new DicomHeader(); - dicomSeriesHeaders.setSize( fileList.getSize() ); + dicomSeriesHeaders.setSize( fileList.size() ); dicomSeriesHeaders.setElement( number, header ); if( !header->loadFromFile( filePath ) ) return false; @@ -283,7 +283,7 @@ inline bool DicomSeries::loadImage( const String& filePath, int number) imagesInfo.frameSize = size; if (pixelData) delete pixelData; - pixelData = new Uint16[imagesInfo.frameUintsCount * fileList.getSize()]; + pixelData = new Uint16[imagesInfo.frameUintsCount * fileList.size()]; } else {//check image size for compatibility @@ -328,13 +328,14 @@ inline bool DicomSeries::loadDicomSeries( const String& filePath ) } //load images - int imagesCountToLoad = fileList.getSize(); - for( int i=0; i < imagesCountToLoad; i++ ) + int counter = 0; + for( auto& file : fileList ) { - if( !loadImage( fileList[ i ].getString(),i ) ) + if( !loadImage( file.getString(), counter ) ) { - std::cerr << fileList[ i ] << " skipped"; + std::cerr << file << " skipped"; } + counter++; } return true; } diff --git a/src/Tools/tnl-dicom-reader.cpp b/src/Tools/tnl-dicom-reader.cpp index f6931e5f47f21b7ce404e6bc90c384b2aeb749d7..c0f770e497b95ba2758cb852a36a3c3ccf562069 100644 --- a/src/Tools/tnl-dicom-reader.cpp +++ b/src/Tools/tnl-dicom-reader.cpp @@ -37,7 +37,7 @@ bool processDicomFiles( const Config::ParameterContainer& parameters ) bool processDicomSeries( const Config::ParameterContainer& parameters ) { - const Containers::List< String >& dicomSeriesNames = parameters.getParameter< Containers::List< String > >( "dicom-series" ); + const std::vector< String >& dicomSeriesNames = parameters.getParameter< std::vector< String > >( "dicom-series" ); String meshFile = parameters.getParameter< String >( "mesh-file" ); bool verbose = parameters.getParameter< bool >( "verbose" ); @@ -45,7 +45,7 @@ bool processDicomSeries( const Config::ParameterContainer& parameters ) GridType grid; Containers::Vector< double, Devices::Host, int > vector; Images::RegionOfInterest< int > roi; - for( int i = 0; i < dicomSeriesNames.getSize(); i++ ) + for( std::size_t i = 0; i < dicomSeriesNames.size(); i++ ) { const String& seriesName = dicomSeriesNames[ i ]; std::cout << "Reading a file " << seriesName << std::endl; diff --git a/src/UnitTests/Containers/CMakeLists.txt b/src/UnitTests/Containers/CMakeLists.txt index 51060d7708d290db443489f68d933359ffa41453..6ff7570dd3b1a62051ce295180205ddac0675156 100644 --- a/src/UnitTests/Containers/CMakeLists.txt +++ b/src/UnitTests/Containers/CMakeLists.txt @@ -1,7 +1,3 @@ -ADD_EXECUTABLE( ListTest ListTest.cpp ) -TARGET_COMPILE_OPTIONS( ListTest PRIVATE ${CXX_TESTS_FLAGS} ) -TARGET_LINK_LIBRARIES( ListTest ${GTEST_BOTH_LIBRARIES} ) - ADD_EXECUTABLE( ArrayTest ArrayTest.cpp ) TARGET_COMPILE_OPTIONS( ArrayTest PRIVATE ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( ArrayTest ${GTEST_BOTH_LIBRARIES} ) @@ -73,7 +69,6 @@ TARGET_COMPILE_OPTIONS( StaticVectorOperationsTest PRIVATE ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( StaticVectorOperationsTest ${GTEST_BOTH_LIBRARIES} ) -ADD_TEST( ListTest ${EXECUTABLE_OUTPUT_PATH}/ListTest${CMAKE_EXECUTABLE_SUFFIX} ) ADD_TEST( ArrayTest ${EXECUTABLE_OUTPUT_PATH}/ArrayTest${CMAKE_EXECUTABLE_SUFFIX} ) ADD_TEST( ArrayViewTest ${EXECUTABLE_OUTPUT_PATH}/ArrayViewTest${CMAKE_EXECUTABLE_SUFFIX} ) ADD_TEST( VectorTest ${EXECUTABLE_OUTPUT_PATH}/VectorTest${CMAKE_EXECUTABLE_SUFFIX} ) diff --git a/src/UnitTests/Containers/ListTest.cpp b/src/UnitTests/Containers/ListTest.cpp deleted file mode 100644 index 072b7500316c6dc350f7370fcb9619e70ae532bc..0000000000000000000000000000000000000000 --- a/src/UnitTests/Containers/ListTest.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - ListTest.cpp - description - ------------------- - begin : Feb 15, 2014 - copyright : (C) 2014 by Tomas Oberhuber et al. - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#ifdef HAVE_GTEST -#include <gtest/gtest.h> - -#include <TNL/Containers/List.h> - -using namespace TNL; -using namespace TNL::Containers; - -// minimal custom data structure usable as ValueType in List -struct MyData -{ - double data; - - __cuda_callable__ - MyData() : data(0) {} - - template< typename T > - __cuda_callable__ - MyData( T v ) : data(v) {} - - __cuda_callable__ - bool operator==( const MyData& v ) const { return data == v.data; } - - __cuda_callable__ - bool operator!=( const MyData& v ) const { return data != v.data; } -}; - -std::ostream& operator<<( std::ostream& str, const MyData& v ) -{ - return str << v.data; -} - - -// test fixture for typed tests -template< typename List > -class ListTest : public ::testing::Test -{ -protected: - using ListType = List; -}; - -// types for which ListTest is instantiated -using ListTypes = ::testing::Types< - List< short >, - List< int >, - List< long >, - List< float >, - List< double >, - List< MyData > ->; - -TYPED_TEST_SUITE( ListTest, ListTypes ); - - -TYPED_TEST( ListTest, constructor ) -{ - using ListType = typename TestFixture::ListType; - using ValueType = typename ListType::ValueType; - - ListType list; - EXPECT_TRUE( list.isEmpty() ); - EXPECT_EQ( list.getSize(), 0 ); - - list.Append( ( ValueType ) 0 ); - EXPECT_EQ( list.getSize(), 1 ); - - ListType copy( list ); - list.Append( ( ValueType ) 0 ); - EXPECT_EQ( list.getSize(), 2 ); - EXPECT_EQ( copy.getSize(), 1 ); - EXPECT_EQ( copy[ 0 ], list[ 0 ] ); -} - -TYPED_TEST( ListTest, operations ) -{ - using ListType = typename TestFixture::ListType; - using ValueType = typename ListType::ValueType; - - ListType a, b; - - a.Append( (ValueType) 0 ); - a.Append( (ValueType) 1 ); - a.Prepend( (ValueType) 2 ); - a.Insert( (ValueType) 3, 1 ); - EXPECT_EQ( a.getSize(), 4 ); - EXPECT_EQ( a[ 0 ], (ValueType) 2 ); - EXPECT_EQ( a[ 1 ], (ValueType) 3 ); - EXPECT_EQ( a[ 2 ], (ValueType) 0 ); - EXPECT_EQ( a[ 3 ], (ValueType) 1 ); - - b = a; - EXPECT_EQ( b.getSize(), 4 ); - EXPECT_EQ( a, b ); - - b.Insert( ( ValueType ) 4, 4 ); - EXPECT_NE( a, b ); - EXPECT_EQ( b[ 4 ], (ValueType) 4 ); - - a.AppendList( b ); - EXPECT_EQ( a.getSize(), 9 ); - EXPECT_EQ( a[ 0 ], (ValueType) 2 ); - EXPECT_EQ( a[ 1 ], (ValueType) 3 ); - EXPECT_EQ( a[ 2 ], (ValueType) 0 ); - EXPECT_EQ( a[ 3 ], (ValueType) 1 ); - EXPECT_EQ( a[ 4 ], (ValueType) 2 ); - EXPECT_EQ( a[ 5 ], (ValueType) 3 ); - EXPECT_EQ( a[ 6 ], (ValueType) 0 ); - EXPECT_EQ( a[ 7 ], (ValueType) 1 ); - EXPECT_EQ( a[ 8 ], (ValueType) 4 ); - - a.PrependList( b ); - EXPECT_EQ( a.getSize(), 14 ); - EXPECT_EQ( a[ 0 ], (ValueType) 2 ); - EXPECT_EQ( a[ 1 ], (ValueType) 3 ); - EXPECT_EQ( a[ 2 ], (ValueType) 0 ); - EXPECT_EQ( a[ 3 ], (ValueType) 1 ); - EXPECT_EQ( a[ 4 ], (ValueType) 4 ); - EXPECT_EQ( a[ 5 ], (ValueType) 2 ); - EXPECT_EQ( a[ 6 ], (ValueType) 3 ); - EXPECT_EQ( a[ 7 ], (ValueType) 0 ); - EXPECT_EQ( a[ 8 ], (ValueType) 1 ); - EXPECT_EQ( a[ 9 ], (ValueType) 2 ); - EXPECT_EQ( a[ 10 ], (ValueType) 3 ); - EXPECT_EQ( a[ 11 ], (ValueType) 0 ); - EXPECT_EQ( a[ 12 ], (ValueType) 1 ); - EXPECT_EQ( a[ 13 ], (ValueType) 4 ); -} -#endif - - -#include "../main.h"