CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   List cannot be trusted...? (http://www.cfd-online.com/Forums/openfoam-programming-development/78359-list-cannot-trusted.html)

marupio July 19, 2010 16:23

List cannot be trusted...?
 
Why does setSize() trash my data?

I have:
Code:

class: equationMaster
{
    List<equation> eqns_;
}

Where equation is itself a list:
Code:

class: equation
:
    public List<operation>
{
    // null constructor, friend operators << and >>
  // construct from components and IStream
}

and operation is
Code:

class: operation
{
  // four labels defined, some with enumeration
  // null constructor, friend operators << and >>
  // construct from components and IStream
}

Now, when I do this:
Code:

eqns_.setSize(eqns_size() + 1);
it trashes my operation list.

Anyone with any ideas what is going on? Have I overused lists?

Any assistance would be appreciated...

-Dave

olesen July 20, 2010 03:04

Quote:

Originally Posted by marupio (Post 268074)
it trashes my operation list.

Anyone with any ideas what is going on? Have I overused lists?

Any assistance would be appreciated...

I'd guess that the copy operation in setSize() might be causing issues.
Without actually knowing anything about your classes, you might nonetheless take a look at PtrList and see it that makes more sense for some of your operations.

marupio July 20, 2010 10:26

Thanks Mark. (I thought it might be a constructor issue.) I did switch to PtrList and it is behaving now.


All times are GMT -4. The time now is 11:58.