|
[Sponsors] |
July 20, 2010, 08:00 |
single linked list iterator does not work
|
#1 |
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Hello All!
I am just trying to create a SLList (single linked list) to store my timedependent data, a scalarField ... I already managed to create the List, but the iterator function is not working... Any Ideas why?? I created a dummy test: Code:
#include "fvCFD.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { scalar t=0; scalarField a(6); SLList<scalarField> test; for (int i=0; i<=5; i++) { a[i]=i; } for (int i=0; i<=5; i++) { a[0]=t; for (int j=1; j<=5; j++) { a[j]+=1; } t++; test.append(a); Info << "test " << test.size() <<endl; Info << "test "<< test.first()<<endl; Info << "test "<< test.last()<<endl; } SLList<scalarField>::iterator iterTest; for( iterTest=test.begin(); iterTest != test.end(); ++iterTest) { Info << "Iterator" << iterTest << endl; } } Tobi |
|
July 20, 2010, 22:02 |
|
#2 |
Member
Jianye Xia
Join Date: Mar 2009
Posts: 32
Rep Power: 18 |
what do u mean the iterater not work? can u post the output of this test code?
|
|
July 21, 2010, 05:15 |
|
#3 |
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Hi,
sure... when I compile it the output is: Code:
Making dependency list for source file test.C test.C: In function ‘int main(int, char**)’: test.C:61: error: no matching function for call to ‘Foam::LList<Foam::SLListBase, Foam::Field<double> >::iterator::iterator()’ ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/LList.H:246: note: candidates are: Foam::LList<LListBase, T>::iterator::iterator(typename LListBase::iterator) [with LListBase = Foam::SLListBase, T = Foam::Field<double>] ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/LList.H:238: note: Foam::LList<Foam::SLListBase, Foam::Field<double> >::iterator::iterator(const Foam::LList<Foam::SLListBase, Foam::Field<double> >::iterator&) test.C:64: error: no match for ‘operator<<’ in ‘Foam::operator<<(((Foam::Ostream&)(&((Foam::OSstream*)Foam::Info.Foam::messageStream::operator Foam::OSstream&())->Foam::OSstream::<anonymous>)), ((const char*)"Iterator")) << iterTest’ ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/scalarRange.H:134: note: candidates are: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::scalarRange&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/lduMatrix.H:840: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::lduMatrix&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/globalMeshData.H:409: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::globalMeshData&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/lduSchedule.H:68: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::lduScheduleEntry&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/cellZone.H:266: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::cellZone&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/faceZone.H:324: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::faceZone&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/pointZone.H:268: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::pointZone&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/boundBox.H:227: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::boundBox&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/polyBoundaryMesh.H:199: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::polyBoundaryMesh&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/polyPatch.H:358: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::polyPatch&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/objectHit.H:123: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::objectHit&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/patchIdentifier.H:150: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::patchIdentifier&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/nil.H:83: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::nil&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/cellShape.H:164: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::cellShape&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/cellModel.H:175: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::cellModel&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/SHA1Digest.H:80: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::SHA1Digest&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/instant.H:147: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::instant&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Switch.H:196: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::Switch&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/dimensionSet.H:296: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::dimensionSet&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/dictionary.H:478: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::dictionary&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/entry.H:177: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::entry&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/long.H:58: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, long int) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Pstream.H:507: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::Pstream::commsStruct&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:433: note: std::ostream& Foam::operator<<(std::ostream&, const Foam::InfoProxy<Foam::token>&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:432: note: std::ostream& Foam::operator<<(std::ostream&, const Foam::token::punctuationToken&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:431: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::token::punctuationToken&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:434: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::token::compound&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/token.H:422: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::token&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/error.H:284: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::IOerror&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/error.H:179: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::error&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Ostream.H:212: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::IOstream& (*)(Foam::IOstream&)) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Ostream.H:206: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::Ostream& (*)(Foam::Ostream&)) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/IOstream.H:556: note: Foam::IOstream& Foam::operator<<(Foam::IOstream&, Foam::IOstream& (*)(Foam::IOstream&)) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/IOstream.H:546: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::IOstream::versionNumber&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/IOstream.H:545: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::IOstream::streamFormat&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/fileName.H:178: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::fileName&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Scalar.H:282: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::doubleScalar) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/Scalar.H:282: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, Foam::floatScalar) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/uint.H:58: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, unsigned int) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/bool.H:50: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, bool) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/int.H:59: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, int) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/word.H:134: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::word&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/string.H:69: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const std::string&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/string.H:215: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::string&) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/char.H:52: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, const char*) ~/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/char.H:51: note: Foam::Ostream& Foam::operator<<(Foam::Ostream&, char) make: *** [Make/linux64GccDPOpt/test.o] Error 1 Tobi |
|
July 21, 2010, 05:21 |
|
#4 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
That won't even compile. The iterator needs one constructor argument:
Code:
for( SLList<scalarField>::iterator iterTest=test1.begin(); iterTest != test1.end(); ++iterTest) { Info << "Iterator" << *iterTest << endl; }
__________________
Laurence R. McGlashan :: Website |
|
July 21, 2010, 05:53 |
|
#5 |
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Hy Laurence,
thanks it works. Do I understand right, that there is no empty constructor for this iterator?? |
|
July 21, 2010, 06:09 |
|
#6 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
Have a look in the source here, from line 235. SLList inherits the iterator from LListBase. It would appear you have to either initialise the iterator with one argument, or implicitly assign an initial iterator value as I have done.
__________________
Laurence R. McGlashan :: Website |
|
July 21, 2010, 22:45 |
|
#7 |
Member
Jianye Xia
Join Date: Mar 2009
Posts: 32
Rep Power: 18 |
Code:
//iterator must be initiated first SLList<scalarField>::iterator iterTest=test.begin(); so you must call the operator() or operator* member function of the iterator first before you output it's value: Code:
Info << "Iterator" << *iterTest << endl; Code:
Info << "Iterator" << iterTest() << endl; |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ATTENTION! Reliability problems in CFX 5.7 | Joseph | CFX | 14 | April 20, 2010 16:45 |
Why my code is ok with single processor but doesnbt work in openmpi | xiuying | OpenFOAM Running, Solving & CFD | 0 | November 23, 2007 14:44 |
Linked list errors | hjasak | OpenFOAM | 0 | October 7, 2005 08:14 |
Linked list errors | hjasak | OpenFOAM | 1 | September 13, 2005 10:56 |
P4 1.5 or Dual P3 800EB on Gibabyte board | Danial | FLUENT | 4 | September 12, 2001 12:44 |