mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add front(), back() methods to List containers
- traditionally used first(), last() methods, but front(), back() are well-known from std::vector etc which makes the access more familiar. - support push_back() method for containers that already had append(). This increases name familiar and can help when porting between different C++ code bases. - support pop_back() method for List containers. This is similar to std::vector
This commit is contained in:
committed by
Andrew Heather
parent
db88265163
commit
c7e6ae30bf
@ -101,6 +101,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
printInfo(idl1);
|
||||
|
||||
Info<< "list() = ";
|
||||
idl1.list().writeList(Info, 0) << endl;
|
||||
|
||||
for (const label val : { 10, 30, 40, 50, 90, 80, 120 } )
|
||||
{
|
||||
testFind(val, idl1);
|
||||
|
||||
@ -334,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
listApp.append(new Scalar(1.3*i));
|
||||
}
|
||||
listApp.emplace_append(100);
|
||||
listApp.emplace_back(100);
|
||||
|
||||
|
||||
Info<< nl
|
||||
@ -580,8 +580,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
PtrList<plane> planes;
|
||||
planes.emplace_append(vector::one, vector::one);
|
||||
planes.emplace_append(vector(1,2,3), vector::one);
|
||||
planes.emplace_back(vector::one, vector::one);
|
||||
planes.emplace_back(vector(1,2,3), vector::one);
|
||||
|
||||
Info<< nl << "appended values" << nl;
|
||||
for (const plane& p : planes)
|
||||
@ -594,15 +594,15 @@ int main(int argc, char *argv[])
|
||||
PtrDynList<plane> dynPlanes;
|
||||
|
||||
{
|
||||
dynPlanes.emplace_append(vector::one, vector::one);
|
||||
dynPlanes.emplace_append(vector(1,2,3), vector::one);
|
||||
dynPlanes.emplace_back(vector::one, vector::one);
|
||||
dynPlanes.emplace_back(vector(1,2,3), vector::one);
|
||||
dynPlanes.append(nullptr);
|
||||
|
||||
dynPlanes.set(6, new plane(vector(2,2,1), vector::one));
|
||||
dynPlanes.set(10, new plane(vector(4,5,6), vector::one));
|
||||
|
||||
dynPlanes.emplace(12, vector(3,2,1), vector::one);
|
||||
dynPlanes.emplace_append(Zero, vector::one);
|
||||
dynPlanes.emplace_back(Zero, vector::one);
|
||||
}
|
||||
|
||||
Info<< nl << "PtrDynList: ";
|
||||
|
||||
Reference in New Issue
Block a user