added xfer<...> transfer() method to various containers

- this should provide a slightly more naturally means to using transfer
  constructors, for example
          labelList list2(list1.transfer());
      vs. labelList list2(xferMove(list1));

- returns a plain list where appropriate (eg, DynamicList, SortableList)
  for example
          labelList list2(dynList1.transfer());
      vs. labelList list2(xferMoveTo<labelList>(dynList1));
This commit is contained in:
Mark Olesen
2009-01-02 15:54:51 +01:00
parent 5e90a0ddc9
commit cf488912bb
22 changed files with 336 additions and 251 deletions

View File

@ -145,6 +145,14 @@ int main(int argc, char *argv[])
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
List<label> lstB(dlC.transfer());
Info<< "Transferred to normal list via the transfer() method" << endl;
Info<< "<lstB>" << lstB << "</lstB>" << nl << "sizes: "
<< " " << lstB.size() << endl;
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
return 0;
}

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
@ -54,6 +54,11 @@ int main(int argc, char *argv[])
list2.setSize(10, vector(1, 2, 3));
Info<< list2 << endl;
List<vector> list3(list2.transfer());
Info<< "Transferred via the transfer() method" << endl;
Info<< list2 << endl;
Info<< list3 << endl;
return 0;
}

View File

@ -104,6 +104,13 @@ int main(int argc, char *argv[])
Info<<"list1: " << list1 << endl;
PtrList<Scalar> list3(list1.transfer());
Info<< "Transferred via the transfer() method" << endl;
Info<<"list1: " << list1 << endl;
Info<<"list2: " << list2 << endl;
Info<<"list3: " << list3 << endl;
Info<< nl << "Done." << endl;
return 0;
}