STYLE: use X.last() method instead of X[X.size()-1]

This commit is contained in:
Mark Olesen
2010-12-07 09:56:52 +01:00
parent f367ee2ece
commit a2b73a1c6d
12 changed files with 15 additions and 17 deletions

View File

@ -260,7 +260,7 @@ cellShape create3DCellShape
meshFaceLabels[i - 1] = meshFaceLabels[i]; meshFaceLabels[i - 1] = meshFaceLabels[i];
} }
meshFaceLabels[meshFaceLabels.size() - 1] = firstLabel; meshFaceLabels.last() = firstLabel;
} }
} }

View File

@ -80,7 +80,7 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p)
<< pName << " in mesh " << caseName << pName << " in mesh " << caseName
<< " already exists, but patch types " << " already exists, but patch types "
<< " do not match.\nCreating a composite name as " << " do not match.\nCreating a composite name as "
<< patchNames_[patchNames_.size() - 1] << endl; << patchNames_.last() << endl;
} }
else else
{ {

View File

@ -150,7 +150,7 @@ void Foam::processorLduInterface::compressedSend
fArray[i] = sArray[i] - slast[i%nCmpts]; fArray[i] = sArray[i] - slast[i%nCmpts];
} }
reinterpret_cast<Type&>(fArray[nm1]) = f[f.size() - 1]; reinterpret_cast<Type&>(fArray[nm1]) = f.last();
if (commsType == Pstream::blocking || commsType == Pstream::scheduled) if (commsType == Pstream::blocking || commsType == Pstream::scheduled)
{ {
@ -235,7 +235,7 @@ void Foam::processorLduInterface::compressedReceive
const float *fArray = const float *fArray =
reinterpret_cast<const float*>(receiveBuf_.begin()); reinterpret_cast<const float*>(receiveBuf_.begin());
f[f.size() - 1] = reinterpret_cast<const Type&>(fArray[nm1]); f.last() = reinterpret_cast<const Type&>(fArray[nm1]);
scalar *sArray = reinterpret_cast<scalar*>(f.begin()); scalar *sArray = reinterpret_cast<scalar*>(f.begin());
const scalar *slast = &sArray[nm1]; const scalar *slast = &sArray[nm1];

View File

@ -750,7 +750,7 @@ Foam::edgeList Foam::face::edges() const
} }
// add last edge // add last edge
e[points.size() - 1] = edge(points[points.size() - 1], points[0]); e.last() = edge(points.last(), points[0]);
return e; return e;
} }

View File

@ -305,7 +305,7 @@ void Foam::meshReader::createPolyBoundary()
if (nMissingFaces > 0) if (nMissingFaces > 0)
{ {
patchSizes_[patchSizes_.size() - 1] = nMissingFaces; patchSizes_.last() = nMissingFaces;
} }
else else
{ {

View File

@ -127,7 +127,7 @@ Foam::label Foam::polyMeshAdder::patchIndex
<< pName << " in mesh " << caseName << pName << " in mesh " << caseName
<< " already exists, but patch types" << " already exists, but patch types"
<< " do not match.\nCreating a composite name as " << " do not match.\nCreating a composite name as "
<< allPatchNames[allPatchNames.size() - 1] << endl; << allPatchNames.last() << endl;
return allPatchNames.size() - 1; return allPatchNames.size() - 1;
} }

View File

@ -519,7 +519,7 @@ void Foam::enrichedPatch::calcCutFaces() const
// Reverse the face such that it // Reverse the face such that it
// points out of the master patch // points out of the master patch
cf[cf.size() - 1].flip(); cf.last().flip();
if (debug) if (debug)
{ {

View File

@ -101,8 +101,8 @@ Foam::swirlInjector::swirlInjector
( (
mag mag
( (
massFlowRateProfile_[massFlowRateProfile_.size() - 1][0] massFlowRateProfile_.last()[0]
- injectionPressureProfile_[injectionPressureProfile_.size() - 1][0] - injectionPressureProfile_.last()[0]
) > SMALL ) > SMALL
) )
{ {

View File

@ -447,9 +447,7 @@ bool Foam::polyMeshZipUpCells(polyMesh& mesh)
point startPoint = Points[unorderedEdge[0]]; point startPoint = Points[unorderedEdge[0]];
dist[0] = 0; dist[0] = 0;
vector dir = vector dir = Points[unorderedEdge.last()] - startPoint;
Points[unorderedEdge[unorderedEdge.size() - 1]]
- startPoint;
for (label i = 1; i < dist.size(); i++) for (label i = 1; i < dist.size(); i++)
{ {
@ -509,7 +507,7 @@ bool Foam::polyMeshZipUpCells(polyMesh& mesh)
edge testEdge edge testEdge
( (
orderedEdge[0], orderedEdge[0],
orderedEdge[orderedEdge.size() - 1] orderedEdge.last()
); );
// In order to avoid edge-to-edge comparison, get faces using // In order to avoid edge-to-edge comparison, get faces using

View File

@ -292,7 +292,7 @@ const Foam::wordList& Foam::searchableSurfaceCollection::regions() const
Foam::label Foam::searchableSurfaceCollection::size() const Foam::label Foam::searchableSurfaceCollection::size() const
{ {
return indexOffset_[indexOffset_.size()-1]; return indexOffset_.last();
} }

View File

@ -238,7 +238,7 @@ void Foam::triSurfaceMesh::getNextIntersections
while (true) while (true)
{ {
// Start tracking from last hit. // Start tracking from last hit.
point pt = hits[hits.size()-1].hitPoint() + perturbVec; point pt = hits.last().hitPoint() + perturbVec;
if (((pt-start)&dirVec) > magSqrDirVec) if (((pt-start)&dirVec) > magSqrDirVec)
{ {

View File

@ -514,7 +514,7 @@ Foam::surfacePatchList Foam::triSurface::calcPatches(labelList& faceMap) const
maxRegion = max maxRegion = max
( (
maxRegion, maxRegion,
operator[](faceMap[faceMap.size() - 1]).region() operator[](faceMap.last()).region()
); );
} }