diff --git a/applications/test/DLList/DLListTest.C b/applications/test/DLList/DLListTest.C index 12913ce8666f661fdd693bc76e1775c090e7a59b..2929efc1ce8d2940aed11d007c9d7b474bef437b 100644 --- a/applications/test/DLList/DLListTest.C +++ b/applications/test/DLList/DLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -48,7 +48,6 @@ int main(int argc, char *argv[]) } myList.append(100.3); - myList.append(500.3); Info<< nl << "And again using STL iterator: " << nl << endl; @@ -120,7 +119,18 @@ int main(int argc, char *argv[]) Info<< "element:" << *iter << endl; } - Info<< nl << "Bye." << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + DLList<scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + + + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/Dictionary/DictionaryTest.C b/applications/test/Dictionary/DictionaryTest.C index ade39072642b83f14e516106797c059676e0ff4f..9c0b2d71f2616d2fe3f0ae4c9c0673ed7ef8d3cc 100644 --- a/applications/test/Dictionary/DictionaryTest.C +++ b/applications/test/Dictionary/DictionaryTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -92,12 +92,11 @@ int main(int argc, char *argv[]) Info<< "element : " << *iter; } - Info<< dict.toc() << endl; + Info<< "keys: " << dict.toc() << endl; delete dictPtr; - dictPtr = new Dictionary<ent>; - Dictionary<ent>& dict2 = *dictPtr; + Dictionary<ent> dict2; for (int i = 0; i<10; i++) { @@ -106,9 +105,20 @@ int main(int argc, char *argv[]) dict2.swapUp(ePtr); } - Info<< dict2 << endl; + Info<< "dict:\n" << dict2 << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << dict2 << endl; + + Dictionary<ent> newDict; + newDict.transfer(dict2); + + Info<< nl << "source: " << dict2 << nl + << "keys: " << dict2.toc() << nl + << "target: " << newDict << nl + << "keys: " << newDict.toc() << endl; - Info<< nl << "Bye." << endl; + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/ISLList/ISLListTest.C b/applications/test/ISLList/ISLListTest.C index 60590d1eafc26468d19167b0e4792ca271381a3c..f33f811c1a4bfa3b705ddacbfef0d734d0771326 100644 --- a/applications/test/ISLList/ISLListTest.C +++ b/applications/test/ISLList/ISLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -52,6 +52,13 @@ public: : data_(s) {} + + friend Ostream& operator<<(Ostream& os, const Scalar& s) + { + os << s.data_; + return os; + } + }; @@ -68,10 +75,8 @@ int main(int argc, char *argv[]) } myList.append(new Scalar(100.3)); - myList.append(new Scalar(500.3)); - Info<< nl << "And again using STL iterator: " << nl << endl; for @@ -99,6 +104,15 @@ int main(int argc, char *argv[]) } + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + ISLList<Scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + Info<< nl << "Bye." << endl; return 0; } diff --git a/applications/test/SLList/SLListTest.C b/applications/test/SLList/SLListTest.C index 3bd9af2b6723a72d8be0f25c1ac76427ecda5977..f55f7b4edf58f533e5f1c242b08bfbbb79beef73 100644 --- a/applications/test/SLList/SLListTest.C +++ b/applications/test/SLList/SLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -48,10 +48,8 @@ int main(int argc, char *argv[]) } myList.append(100.3); - myList.append(500.3); - Info<< nl << "And again using STL iterator: " << nl << endl; for @@ -99,7 +97,27 @@ int main(int argc, char *argv[]) Info<< "element:" << *iter2 << endl; } - Info<< nl << "Bye." << endl; + + + for (int i = 0; i<10; i++) + { + myList.append(1.3*i); + } + + myList.append(100.3); + myList.append(500.3); + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + SLList<scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + + + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/UDictionary/UDictionaryTest.C b/applications/test/UDictionary/UDictionaryTest.C index 5caea16dad9e959c73d5c7911b938a300df9f8ec..247fc98cbb6b0d20e0c8111881d21606631fad2a 100644 --- a/applications/test/UDictionary/UDictionaryTest.C +++ b/applications/test/UDictionary/UDictionaryTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -113,7 +113,20 @@ int main(int argc, char *argv[]) Info<< dict2 << endl; - Info<< nl << "Bye." << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << dict2 << endl; + + UDictionary<ent> newDict; + newDict.transfer(dict2); + + Info<< nl << "source: " << dict2 << nl + << "keys: " << dict2.toc() << nl + << "target: " << newDict << nl + << "keys: " << newDict.toc() << endl; + + Info<< nl << "Done." << endl; + return 0; } diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C index b8ce241f094d4b2422dde90d878414b39f220d8b..95112712081129e65f9331a7592fcb89ab9429ad 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C @@ -237,6 +237,17 @@ void Foam::DictionaryBase<IDLListType, T>::clear() } +template<class IDLListType, class T> +void Foam::DictionaryBase<IDLListType, T>::transfer +( + DictionaryBase<IDLListType, T>& dict +) +{ + IDLListType::transfer(dict); + hashedTs_.transfer(dict.hashedTs_); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class IDLListType, class T> diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H index 63566cc4c1e4272352fa833ed1b67104650273e7..f14785bcd555ae5a8737623024e6d15de146d82f 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H @@ -143,6 +143,9 @@ public: //- Clear the dictionary void clear(); + //- Transfer the contents of the argument into this DictionaryBase + // and annull the argument. + void transfer(DictionaryBase<IDLListType, T>&); // Member operators