consistency update

- DynamicList gets append methods as per List
- misc cosmetic changes
This commit is contained in:
Mark Olesen
2009-04-27 10:08:29 +02:00
parent 6ce8e7d0c0
commit 48247a3d62
24 changed files with 210 additions and 176 deletions

View File

@ -160,18 +160,33 @@ int main(int argc, char *argv[])
<< " " << lstB.size() << endl; << " " << lstB.size() << endl;
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: " Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
<< " " << dlD.size() << "/" << dlD.capacity() << endl; << " " << dlD.size() << "/" << dlD.capacity() << endl;
DynamicList<label,10> dlE1(10); DynamicList<label,10> dlE1(10);
DynamicList<label> dlE2(dlE1); DynamicList<label> dlE2(dlE1); // construct dissimilar
Info<< "<dlE1>" << dlE1 << "</dlE1>" << nl << "sizes: " Info<< "<dlE1>" << dlE1 << "</dlE1>" << nl << "sizes: "
<< " " << dlE1.size() << "/" << dlE1.capacity() << endl; << " " << dlE1.size() << "/" << dlE1.capacity() << endl;
Info<< "<dlE2>" << dlE2 << "</dlE2>" << nl << "sizes: " Info<< "<dlE2>" << dlE2 << "</dlE2>" << nl << "sizes: "
<< " " << dlE2.size() << "/" << dlE2.capacity() << endl; << " " << dlE2.size() << "/" << dlE2.capacity() << endl;
dlE2.append(100); for (label elemI=0; elemI < 5; ++elemI)
{
dlE1.append(4 - elemI);
dlE2.append(elemI);
}
Info<< "<dlE2>" << dlE2 << "</dlE2>" << endl; Info<< "<dlE2>" << dlE2 << "</dlE2>" << endl;
DynamicList<label> dlE3(dlE2); // construct identical
Info<< "<dlE3>" << dlE3 << "</dlE3>" << endl;
dlE3 = dlE1; // assign dissimilar
Info<< "<dlE3>" << dlE3 << "</dlE3>" << endl;
dlE3 = dlE2; // assign identical
Info<< "<dlE3>" << dlE3 << "</dlE3>" << endl;
Info<< "\nEnd\n"; Info<< "\nEnd\n";
return 0; return 0;

View File

@ -39,7 +39,7 @@ using namespace Foam;
int main() int main()
{ {
HASHTABLE_CLASS<double> table1(100); HASHTABLE_CLASS<double> table1(13);
table1.insert("aaa", 1.0); table1.insert("aaa", 1.0);
table1.insert("aba", 2.0); table1.insert("aba", 2.0);
@ -56,7 +56,8 @@ int main()
table1.erase("abs"); table1.erase("abs");
Info<< "\ntable1 toc: " << table1.toc() << endl; Info<< "\ntable1 toc: " << table1.toc() << endl;
Info<< "\ntable1 [" << table1.size() << "] " << endl; table1.printInfo(Info)
<< "table1 [" << table1.size() << "] " << endl;
forAllIter(HASHTABLE_CLASS<double>, table1, iter) forAllIter(HASHTABLE_CLASS<double>, table1, iter)
{ {
Info<< iter.key() << " => " << iter() << nl; Info<< iter.key() << " => " << iter() << nl;
@ -97,7 +98,7 @@ int main()
<< "transfer table1 -> table3 via the xfer() method" << nl; << "transfer table1 -> table3 via the xfer() method" << nl;
Info<< "\ntable1" << table1 << nl Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table1 << nl << "\ntable2" << table2 << nl
<< "\ntable3" << table3 << nl; << "\ntable3" << table3 << nl;
Info<< "\nerase table2 by iterator" << nl; Info<< "\nerase table2 by iterator" << nl;
@ -113,10 +114,14 @@ int main()
<< "\ntable3" << table3 << nl; << "\ntable3" << table3 << nl;
table3.resize(1); table3.resize(1);
Info<< "\nresize(1) table3" << table3 << nl; Info<< "\nresize(1) table3" << nl;
table3.printInfo(Info)
<< table3 << nl;
table3.resize(10000); table3.resize(10000);
Info<< "\nresize(10000) table3" << table3 << nl; Info<< "\nresize(10000) table3" << nl;
table3.printInfo(Info)
<< table3 << nl;
HASHTABLE_CLASS<double> table4; HASHTABLE_CLASS<double> table4;
@ -134,26 +139,27 @@ int main()
table1.erase(table1.begin()); table1.erase(table1.begin());
Info<< "removed an element - test table1 != table3 : " Info<< "removed an element - test table1 != table3 : "
<< (table1 != table3) << nl; << (table1 != table3) << nl;
// insert a few things into table2 // insert a few things into table2
table2.set("ada", 14.0); table2.set("ada", 14.0);
table2.set("aeq", 15.0); table2.set("aeq", 15.0);
table2.set("aaw", 16.0); table2.set("aaw", 16.0);
table2.set("abs", 17.0); table2.set("abs", 17.0);
table2.set("adx", 20.0); table2.set("adx", 20.0);
Info<< "\ntable1" << table1 << nl Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl; << "\ntable2" << table2 << nl;
label nErased = table1.erase(table2); label nErased = table1.erase(table2);
Info<< "\nerase table2 keys from table1 (removed " Info<< "\nerase table2 keys from table1 (removed "
<< nErased << " elements)" << nl << nErased << " elements)" << nl
<< "\ntable1" << table1 << nl << "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl; << "\ntable2" << table2 << nl;
Info<< "\nclearStorage table3 ... "; Info<< "\ntable3" << table3
<< "\nclearStorage table3 ... ";
table3.clearStorage(); table3.clearStorage();
Info<< table3 << nl; Info<< table3 << nl;

View File

@ -39,7 +39,7 @@ using namespace Foam;
int main() int main()
{ {
HASHTABLE_CLASS<double> table1(100); HASHTABLE_CLASS<double> table1(13);
table1.insert("aaa", 1.0); table1.insert("aaa", 1.0);
table1.insert("aba", 2.0); table1.insert("aba", 2.0);
@ -56,7 +56,8 @@ int main()
table1.erase("abs"); table1.erase("abs");
Info<< "\ntable1 toc: " << table1.toc() << endl; Info<< "\ntable1 toc: " << table1.toc() << endl;
Info<< "\ntable1 [" << table1.size() << "] " << endl; table1.printInfo(Info)
<< "table1 [" << table1.size() << "] " << endl;
forAllIter(HASHTABLE_CLASS<double>, table1, iter) forAllIter(HASHTABLE_CLASS<double>, table1, iter)
{ {
Info<< iter.key() << " => " << iter() << nl; Info<< iter.key() << " => " << iter() << nl;
@ -97,7 +98,7 @@ int main()
<< "transfer table1 -> table3 via the xfer() method" << nl; << "transfer table1 -> table3 via the xfer() method" << nl;
Info<< "\ntable1" << table1 << nl Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table1 << nl << "\ntable2" << table2 << nl
<< "\ntable3" << table3 << nl; << "\ntable3" << table3 << nl;
Info<< "\nerase table2 by iterator" << nl; Info<< "\nerase table2 by iterator" << nl;
@ -113,10 +114,14 @@ int main()
<< "\ntable3" << table3 << nl; << "\ntable3" << table3 << nl;
table3.resize(1); table3.resize(1);
Info<< "\nresize(1) table3" << table3 << nl; Info<< "\nresize(1) table3" << nl;
table3.printInfo(Info)
<< table3 << nl;
table3.resize(10000); table3.resize(10000);
Info<< "\nresize(10000) table3" << table3 << nl; Info<< "\nresize(10000) table3" << nl;
table3.printInfo(Info)
<< table3 << nl;
HASHTABLE_CLASS<double> table4; HASHTABLE_CLASS<double> table4;
@ -134,26 +139,27 @@ int main()
table1.erase(table1.begin()); table1.erase(table1.begin());
Info<< "removed an element - test table1 != table3 : " Info<< "removed an element - test table1 != table3 : "
<< (table1 != table3) << nl; << (table1 != table3) << nl;
// insert a few things into table2 // insert a few things into table2
table2.set("ada", 14.0); table2.set("ada", 14.0);
table2.set("aeq", 15.0); table2.set("aeq", 15.0);
table2.set("aaw", 16.0); table2.set("aaw", 16.0);
table2.set("abs", 17.0); table2.set("abs", 17.0);
table2.set("adx", 20.0); table2.set("adx", 20.0);
Info<< "\ntable1" << table1 << nl Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl; << "\ntable2" << table2 << nl;
label nErased = table1.erase(table2); label nErased = table1.erase(table2);
Info<< "\nerase table2 keys from table1 (removed " Info<< "\nerase table2 keys from table1 (removed "
<< nErased << " elements)" << nl << nErased << " elements)" << nl
<< "\ntable1" << table1 << nl << "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl; << "\ntable2" << table2 << nl;
Info<< "\nclearStorage table3 ... "; Info<< "\ntable3" << table3
<< "\nclearStorage table3 ... ";
table3.clearStorage(); table3.clearStorage();
Info<< table3 << nl; Info<< table3 << nl;
@ -162,4 +168,5 @@ int main()
return 0; return 0;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,6 +27,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "UIndirectList.H" #include "UIndirectList.H"
#include "DynamicList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "ListOps.H" #include "ListOps.H"
#include "OFstream.H" #include "OFstream.H"
@ -58,11 +59,11 @@ int main(int argc, char *argv[])
idl[1] = -666; idl[1] = -666;
Info<< "idl[1] changed:" << idl << endl; Info<< "idl[1] changed: " << idl << endl;
idl = -999; idl = -999;
Info<< "idl changed:" << idl << endl; Info<< "idl changed: " << idl << endl;
UIndirectList<double> idl2(idl); UIndirectList<double> idl2(idl);
@ -79,17 +80,26 @@ int main(int argc, char *argv[])
idl = ident; idl = ident;
} }
Info<< "idl assigned from UList:" << idl << endl; Info<< "idl assigned from UList: " << idl << endl;
List<double> realList = UIndirectList<double>(completeList, addresses); // test List operations
Info<< "realList:" << realList << endl; List<double> flatList = UIndirectList<double>(completeList, addresses);
Info<< "List assigned from UIndirectList: " << flatList << endl;
List<double> realList2(UIndirectList<double>(completeList, addresses)); List<double> flatList2(UIndirectList<double>(completeList, addresses));
Info<< "List constructed from UIndirectList: " << flatList2 << endl;
Info<< "realList2:" << realList2 << endl; flatList.append(UIndirectList<double>(completeList, addresses));
Info<< "List::append(UIndirectList): " << flatList << endl;
DynamicList<double> dynList(UIndirectList<double>(completeList, addresses));
Info<< "DynamicList constructed from UIndirectList: " << dynList << endl;
dynList.append(UIndirectList<double>(completeList, addresses));
Info<< "DynamicList::append(UIndirectList): " << dynList << endl;
Info << "\nEnd\n" << endl; Info << "\nEnd\n" << endl;
return 0; return 0;

View File

@ -50,7 +50,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
label s = firstToken.labelToken(); label s = firstToken.labelToken();
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("HashPtrTable<T, Key, Hash>"); char delimiter = is.readBeginList("HashPtrTable<T, Key, Hash>");
if (s) if (s)
{ {
@ -59,7 +59,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
this->resize(2*s); this->resize(2*s);
} }
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (label i=0; i<s; i++) for (label i=0; i<s; i++)
{ {

View File

@ -28,6 +28,13 @@ Class
Description Description
An STL-conforming hash table. An STL-conforming hash table.
Note
Hashing index collisions are handled via chaining using a singly-linked
list with the colliding entry being added to the head of the linked
list. Thus copying the hash table (or indeed even resizing it) will
often result in a different hash order. Use a sorted table-of-contents
when the hash order is important.
SourceFiles SourceFiles
HashTableI.H HashTableI.H
HashTable.C HashTable.C

View File

@ -81,7 +81,7 @@ Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const
os << "HashTable<T,Key,Hash>" os << "HashTable<T,Key,Hash>"
<< " elements:" << size() << " slots:" << used << "/" << tableSize_ << " elements:" << size() << " slots:" << used << "/" << tableSize_
<< " chaining(avg/max):" << (used ? float(avgChain/used) : 0) << " chaining(avg/max):" << (used ? (float(avgChain)/used) : 0)
<< "/" << maxChain << endl; << "/" << maxChain << endl;
return os; return os;
@ -91,7 +91,11 @@ Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L) Foam::Istream& Foam::operator>>
(
Istream& is,
HashTable<T, Key, Hash>& L
)
{ {
is.fatalCheck("operator>>(Istream&, HashTable<T, Key, Hash>&)"); is.fatalCheck("operator>>(Istream&, HashTable<T, Key, Hash>&)");
@ -113,7 +117,7 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
label s = firstToken.labelToken(); label s = firstToken.labelToken();
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("HashTable<T, Key, Hash>"); char delimiter = is.readBeginList("HashTable<T, Key, Hash>");
if (s) if (s)
{ {
@ -122,7 +126,7 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
L.resize(2*s); L.resize(2*s);
} }
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (label i=0; i<s; i++) for (label i=0; i<s; i++)
{ {
@ -209,7 +213,11 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
Foam::Ostream& Foam::operator<<(Ostream& os, const HashTable<T, Key, Hash>& L) Foam::Ostream& Foam::operator<<
(
Ostream& os,
const HashTable<T, Key, Hash>& L
)
{ {
// Write size and start delimiter // Write size and start delimiter
os << nl << L.size() << nl << token::BEGIN_LIST << nl; os << nl << L.size() << nl << token::BEGIN_LIST << nl;

View File

@ -117,7 +117,7 @@ Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
label s = firstToken.labelToken(); label s = firstToken.labelToken();
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("StaticHashTable<T, Key, Hash>"); char delimiter = is.readBeginList("StaticHashTable<T, Key, Hash>");
if (s) if (s)
{ {
@ -126,7 +126,7 @@ Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
L.resize(2*s); L.resize(2*s);
} }
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (label i=0; i<s; i++) for (label i=0; i<s; i++)
{ {

View File

@ -50,11 +50,11 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
label s = firstToken.labelToken(); label s = firstToken.labelToken();
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("ILList<LListBase, T>"); char delimiter = is.readBeginList("ILList<LListBase, T>");
if (s) if (s)
{ {
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (label i=0; i<s; i++) for (label i=0; i<s; i++)
{ {

View File

@ -61,11 +61,11 @@ Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
label s = firstToken.labelToken(); label s = firstToken.labelToken();
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("LList<LListBase, T>"); char delimiter = is.readBeginList("LList<LListBase, T>");
if (s) if (s)
{ {
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (register label i=0; i<s; i++) for (register label i=0; i<s; i++)
{ {

View File

@ -53,11 +53,11 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
label s = firstToken.labelToken(); label s = firstToken.labelToken();
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("LPtrList<LListBase, T>"); char delimiter = is.readBeginList("LPtrList<LListBase, T>");
if (s) if (s)
{ {
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (label i=0; i<s; i++) for (label i=0; i<s; i++)
{ {

View File

@ -111,8 +111,11 @@ public:
// Also constructs from DynamicList with different sizing parameters. // Also constructs from DynamicList with different sizing parameters.
explicit inline DynamicList(const UList<T>&); explicit inline DynamicList(const UList<T>&);
//- Construct from UIndirectList. Size set to UIndirectList size.
explicit inline DynamicList(const UIndirectList<T>&);
//- Construct by transferring the parameter contents //- Construct by transferring the parameter contents
explicit inline DynamicList(const Xfer<List<T> >&); explicit inline DynamicList(const Xfer< List<T> >&);
//- Construct from Istream. Size set to size of read list. //- Construct from Istream. Size set to size of read list.
explicit DynamicList(Istream&); explicit DynamicList(Istream&);
@ -173,16 +176,19 @@ public:
inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&); inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
//- Transfer contents to the Xfer container as a plain List //- Transfer contents to the Xfer container as a plain List
inline Xfer<List<T> > xfer(); inline Xfer< List<T> > xfer();
// Member Operators // Member Operators
//- Append an element at the end of the list //- Append an element at the end of the list
inline void append(const T& e); inline void append(const T&);
//- Append a List at the end of this list //- Append a List at the end of this list
inline void append(const UList<T>&); inline void append(const UList<T>&);
//- Append a UIndirectList at the end of this list
inline void append(const UIndirectList<T>&);
//- Remove and return the top element //- Remove and return the top element
inline T remove(); inline T remove();
@ -198,7 +204,7 @@ public:
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
); );
//- Assignment from List<T>. //- Assignment from UList
inline void operator=(const UList<T>&); inline void operator=(const UList<T>&);
// IOstream operators // IOstream operators

View File

@ -72,6 +72,17 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
{} {}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
(
const UIndirectList<T>& lst
)
:
List<T>(lst),
capacity_(lst.size())
{}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
( (
@ -287,10 +298,10 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::Xfer<Foam::List<T> > inline Foam::Xfer< Foam::List<T> >
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer() Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer()
{ {
return xferMoveTo<List<T> >(*this); return xferMoveTo< List<T> >(*this);
} }
@ -313,8 +324,6 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
const UList<T>& lst const UList<T>& lst
) )
{ {
label nextFree = List<T>::size();
if (this == &lst) if (this == &lst)
{ {
FatalErrorIn FatalErrorIn
@ -324,6 +333,23 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
) << "attempted appending to self" << abort(FatalError); ) << "attempted appending to self" << abort(FatalError);
} }
label nextFree = List<T>::size();
setSize(nextFree + lst.size());
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
(
const UIndirectList<T>& lst
)
{
label nextFree = List<T>::size();
setSize(nextFree + lst.size()); setSize(nextFree + lst.size());
forAll(lst, elemI) forAll(lst, elemI)

View File

@ -82,9 +82,9 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
} }
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("FixedList"); char delimiter = is.readBeginList("FixedList");
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (register unsigned i=0; i<Size; i++) for (register unsigned i=0; i<Size; i++)
{ {

View File

@ -404,61 +404,6 @@ void Foam::List<T>::clear()
} }
template<class T>
void Foam::List<T>::append(const UList<T>& lst)
{
if (this == &lst)
{
FatalErrorIn
(
"List<T>::append(const UList<T>&)"
) << "attempted appending to self" << abort(FatalError);
}
label nextFree = this->size_;
setSize(nextFree + lst.size());
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
template<class T>
void Foam::List<T>::append(const UIndirectList<T>& lst)
{
label nextFree = this->size_;
setSize(nextFree + lst.size());
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
template<class T>
void Foam::List<T>::append(const SLList<T>& lst)
{
if (lst.size())
{
label nextFree = this->size_;
setSize(nextFree + lst.size());
for
(
typename SLList<T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
this->operator[](nextFree++) = iter();
}
}
}
// Transfer the contents of the argument List into this List // Transfer the contents of the argument List into this List
// and anull the argument list // and anull the argument list
template<class T> template<class T>

View File

@ -182,24 +182,21 @@ public:
void clear(); void clear();
//- Append a List at the end of this list //- Append a List at the end of this list
void append(const UList<T>&); inline void append(const UList<T>&);
//- Append a UIndirectList at the end of this list //- Append a UIndirectList at the end of this list
void append(const UIndirectList<T>&); inline void append(const UIndirectList<T>&);
//- Append a SLList at the end of this list //- Transfer the contents of the argument List into this list
void append(const SLList<T>&);
//- Transfer the contents of the argument List into this List
// and annull the argument list. // and annull the argument list.
void transfer(List<T>&); void transfer(List<T>&);
//- Transfer the contents of the argument List into this List //- Transfer the contents of the argument List into this list
// and annull the argument list. // and annull the argument list.
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&); void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
//- Transfer the contents of the argument List into this List //- Transfer the contents of the argument List into this list
// and annull the argument list. // and annull the argument list.
void transfer(SortableList<T>&); void transfer(SortableList<T>&);

View File

@ -88,12 +88,46 @@ inline Foam::label Foam::List<T>::size() const
template<class T> template<class T>
inline Foam::Xfer<Foam::List<T> > Foam::List<T>::xfer() inline Foam::Xfer< Foam::List<T> > Foam::List<T>::xfer()
{ {
return xferMove(*this); return xferMove(*this);
} }
template<class T>
inline void Foam::List<T>::append(const UList<T>& lst)
{
if (this == &lst)
{
FatalErrorIn
(
"List<T>::append(const UList<T>&)"
) << "attempted appending to self" << abort(FatalError);
}
label nextFree = this->size();
setSize(nextFree + lst.size());
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
template<class T>
inline void Foam::List<T>::append(const UIndirectList<T>& lst)
{
label nextFree = this->size();
setSize(nextFree + lst.size());
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T> template<class T>

View File

@ -76,11 +76,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
if (is.format() == IOstream::ASCII || !contiguous<T>()) if (is.format() == IOstream::ASCII || !contiguous<T>())
{ {
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("List"); char delimiter = is.readBeginList("List");
if (s) if (s)
{ {
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
for (register label i=0; i<s; i++) for (register label i=0; i<s; i++)
{ {

View File

@ -54,11 +54,11 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
setSize(s); setSize(s);
// Read beginning of contents // Read beginning of contents
char listDelimiter = is.readBeginList("PtrList"); char delimiter = is.readBeginList("PtrList");
if (s) if (s)
{ {
if (listDelimiter == token::BEGIN_LIST) if (delimiter == token::BEGIN_LIST)
{ {
forAll(*this, i) forAll(*this, i)
{ {

View File

@ -177,7 +177,7 @@ inline Cmpt det(const SphericalTensor<Cmpt>& st)
} }
//- Return the inverse of a symmetric tensor //- Return the inverse of a spherical tensor
template <class Cmpt> template <class Cmpt>
inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st) inline SphericalTensor<Cmpt> inv(const SphericalTensor<Cmpt>& st)
{ {

View File

@ -256,7 +256,7 @@ inline Cmpt magSqr(const SymmTensor<Cmpt>& st)
} }
//- Return the strace of a symmetric tensor //- Return the trace of a symmetric tensor
template <class Cmpt> template <class Cmpt>
inline Cmpt tr(const SymmTensor<Cmpt>& st) inline Cmpt tr(const SymmTensor<Cmpt>& st)
{ {
@ -280,7 +280,7 @@ inline const SymmTensor<Cmpt>& symm(const SymmTensor<Cmpt>& st)
} }
//- Return the stwice the symmetric part of a symmetric tensor //- Return twice the symmetric part of a symmetric tensor
template <class Cmpt> template <class Cmpt>
inline SymmTensor<Cmpt> twoSymm(const SymmTensor<Cmpt>& st) inline SymmTensor<Cmpt> twoSymm(const SymmTensor<Cmpt>& st)
{ {
@ -361,7 +361,7 @@ inline SymmTensor<Cmpt> inv(const SymmTensor<Cmpt>& st)
} }
//- Return the 1spt invariant of a symmetric tensor //- Return the 1st invariant of a symmetric tensor
template <class Cmpt> template <class Cmpt>
inline Cmpt invariantI(const SymmTensor<Cmpt>& st) inline Cmpt invariantI(const SymmTensor<Cmpt>& st)
{ {
@ -453,14 +453,9 @@ operator&(const SphericalTensor<Cmpt>& spt1, const SymmTensor<Cmpt>& st2)
{ {
return SymmTensor<Cmpt> return SymmTensor<Cmpt>
( (
spt1.ii()*st2.xx(), spt1.ii()*st2.xx(), spt1.ii()*st2.xy(), spt1.ii()*st2.xz(),
spt1.ii()*st2.xy(), spt1.ii()*st2.yy(), spt1.ii()*st2.yz(),
spt1.ii()*st2.xz(), spt1.ii()*st2.zz()
spt1.ii()*st2.yy(),
spt1.ii()*st2.yz(),
spt1.ii()*st2.zz()
); );
} }
@ -472,14 +467,9 @@ operator&(const SymmTensor<Cmpt>& st1, const SphericalTensor<Cmpt>& spt2)
{ {
return SymmTensor<Cmpt> return SymmTensor<Cmpt>
( (
st1.xx()*spt2.ii(), st1.xx()*spt2.ii(), st1.xy()*spt2.ii(), st1.xz()*spt2.ii(),
st1.xy()*spt2.ii(), st1.yy()*spt2.ii(), st1.yz()*spt2.ii(),
st1.xz()*spt2.ii(), st1.zz()*spt2.ii()
st1.yy()*spt2.ii(),
st1.yz()*spt2.ii(),
st1.zz()*spt2.ii()
); );
} }

View File

@ -25,7 +25,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "symmTensor.H" #include "symmTensor.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -65,16 +64,16 @@ template<>
const symmTensor symmTensor::max const symmTensor symmTensor::max
( (
VGREAT, VGREAT, VGREAT, VGREAT, VGREAT, VGREAT,
VGREAT, VGREAT, VGREAT, VGREAT,
VGREAT VGREAT
); );
template<> template<>
const symmTensor symmTensor::min const symmTensor symmTensor::min
( (
-VGREAT, -VGREAT, -VGREAT, -VGREAT, -VGREAT, -VGREAT,
-VGREAT, -VGREAT, -VGREAT, -VGREAT,
-VGREAT -VGREAT
); );

View File

@ -402,7 +402,7 @@ inline SymmTensor<Cmpt> symm(const Tensor<Cmpt>& t)
} }
//- Return the twice the symmetric part of a tensor //- Return twice the symmetric part of a tensor
template <class Cmpt> template <class Cmpt>
inline SymmTensor<Cmpt> twoSymm(const Tensor<Cmpt>& t) inline SymmTensor<Cmpt> twoSymm(const Tensor<Cmpt>& t)
{ {
@ -609,17 +609,9 @@ operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
{ {
return Tensor<Cmpt> return Tensor<Cmpt>
( (
st1.ii()*t2.xx(), st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
st1.ii()*t2.xy(), st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
st1.ii()*t2.xz(), st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
st1.ii()*t2.yx(),
st1.ii()*t2.yy(),
st1.ii()*t2.yz(),
st1.ii()*t2.zx(),
st1.ii()*t2.zy(),
st1.ii()*t2.zz()
); );
} }
@ -631,17 +623,9 @@ operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
{ {
return Tensor<Cmpt> return Tensor<Cmpt>
( (
t1.xx()*st2.ii(), t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
t1.xy()*st2.ii(), t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
t1.xz()*st2.ii(), t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
t1.yx()*st2.ii(),
t1.yy()*st2.ii(),
t1.yz()*st2.ii(),
t1.zx()*st2.ii(),
t1.zy()*st2.ii(),
t1.zz()*st2.ii()
); );
} }

View File

@ -51,13 +51,13 @@ namespace Foam
typedef Tensor<scalar> tensor; typedef Tensor<scalar> tensor;
vector eigenValues(const tensor& t); vector eigenValues(const tensor&);
vector eigenVector(const tensor& t, const scalar lambda); vector eigenVector(const tensor&, const scalar lambda);
tensor eigenVectors(const tensor& t); tensor eigenVectors(const tensor&);
vector eigenValues(const symmTensor& t); vector eigenValues(const symmTensor&);
vector eigenVector(const symmTensor& t, const scalar lambda); vector eigenVector(const symmTensor&, const scalar lambda);
tensor eigenVectors(const symmTensor& t); tensor eigenVectors(const symmTensor&);
//- Data associated with tensor type are contiguous //- Data associated with tensor type are contiguous
template<> template<>