Commit a8278f71 authored by Mark Olesen's avatar Mark Olesen

ENH: align method names with OpenFOAM 1712 container method names

    containsAtPosition   -> find
    contains             -> found

    lastElement          -> last
    removeLastElement    -> remove()
    removeElement(int)   -> [TODO]  remove(int, bool)

    fcElement -> fcValue
    rcElement -> rcValue
parent 109565f5
......@@ -513,13 +513,13 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
for (label i = 0; i < pFaces.size(); ++i)
{
const DynList<label, 8>& bf = pFaces[i];
const label pos = bf.containsAtPosition(gpI);
const label pos = bf.find(gpI);
const edge e(bf[pos], bf[bf.fcIndex(pos)]);
for (label j = i + 1; j < pFaces.size(); ++j)
{
const DynList<label, 8>& obf = pFaces[j];
if (obf.contains(e.start()) && obf.contains(e.end()))
const auto& obf = pFaces[j];
if (obf.found(e.start()) && obf.found(e.end()))
{
DynList<label, 8> add;
add = pFaces[i + 1];
......
......@@ -460,7 +460,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether()
while (front.size())
{
const label fPatch = front.removeLastElement();
const label fPatch = front.remove();
forAll(treatPatchesWithPatch_[fPatch], i)
{
......
......@@ -252,7 +252,7 @@ point boundaryLayers::createNewVertex
forAllRow(pFaces, bpI, pfI)
{
const label faceLabel = pFaces(bpI, pfI);
if (otherPatches.contains(boundaryFacePatches[faceLabel]))
if (otherPatches.found(boundaryFacePatches[faceLabel]))
{
const face& f = bFaces[faceLabel];
const label pos = f.which(bPoints[bpI]);
......@@ -585,7 +585,7 @@ void boundaryLayers::createNewVertices(const labelList& patchLabels)
const std::pair<label, label> pr(pKey, pKey);
const std::map<std::pair<label, label>, label>::const_iterator it =
m.find(pr);
if ((it != m.end()) && !usedPatches.contains(pKey))
if ((it != m.end()) && !usedPatches.found(pKey))
{
usedPatches.append(pKey);
newNodeLabel.append(it->second);
......@@ -1084,7 +1084,7 @@ void boundaryLayers::createNewEdgeVerticesParallel
forAllRow(pFaces, bpI, pfI)
{
const label faceLabel = pFaces(bpI, pfI);
if (otherPatches.contains(boundaryFacePatches[faceLabel]))
if (otherPatches.found(boundaryFacePatches[faceLabel]))
{
const face& f = bFaces[faceLabel];
const label pos = f.which(bPoints[bpI]);
......
......@@ -283,7 +283,7 @@ void boundaryLayers::createNewFacesParallel
}
const label bfI = edgeFaces(beI, 0);
const label pos = faceEdges.containsAtPosition(bfI, beI);
const label pos = faceEdges.find(bfI, beI);
const edge e = bFaces[bfI].faceEdge(pos);
if (otherFaceProc[beI] > Pstream::myProcNo())
......
......@@ -548,7 +548,7 @@ bool detectBoundaryLayers::findHairsForFace
{
const edge e = f.faceEdge(eI);
label pos = edges.containsAtPosition(e);
label pos = edges.find(e);
if (pos < 0)
{
......@@ -605,8 +605,8 @@ bool detectBoundaryLayers::findHairsForFace
{
if
(
edgeFaces[commonEdge].contains(otherNextFace) &&
edgeFaces[commonEdge].contains(otherPrevFace)
edgeFaces[commonEdge].found(otherNextFace)
&& edgeFaces[commonEdge].found(otherPrevFace)
)
{
break;
......
......@@ -555,7 +555,7 @@ void extrudeLayer::createNewVertices()
while (front.size() != 0)
{
const label eLabel = front.removeLastElement();
const label eLabel = front.remove();
forAll(dEdges, eJ)
{
......@@ -693,7 +693,7 @@ void extrudeLayer::createNewVertices()
while (front.size())
{
const label fLabel = front.removeLastElement();
const label fLabel = front.remove();
const label own = owner[pointFaces(pointI, fLabel)];
const label nei = neighbour[pointFaces(pointI, fLabel)];
......@@ -1278,7 +1278,7 @@ void extrudeLayer::createLayerCells()
// find another face attached to the edge eI
const label fFace = adc.faceSharingEdge(extI, eI);
const label pos = pointFaces.containsAtPosition(pointI, fFace);
const label pos = pointFaces.find(pointI, fFace);
// find an extrusion face attached to the edge consisting of points
// origFacePointI and origFaceNextI
......@@ -1432,9 +1432,9 @@ void extrudeLayer::updateBoundary()
forAllRow(pointPatches, bpI, ppI)
{
const label patchI = pointPatches(bpI, ppI);
if (patches.contains(patchI))
if (patches.found(patchI))
{
++nAppearances[patches.containsAtPosition(patchI)];
++nAppearances[patches.find(patchI)];
}
else
{
......
......@@ -201,9 +201,9 @@ void refineBoundaryLayers::generateNewCellsPrism
forAll(f, eI)
{
const edge e(f[eI], f.fcElement(eI));
const edge e(f[eI], f.fcValue(eI));
const label pos = edges.containsAtPosition(e);
const label pos = edges.find(e);
if (pos < 0)
{
......@@ -1004,12 +1004,12 @@ void refineBoundaryLayers::refineCornerHexCell::generateNewPoints()
pointFieldPMG& points = bndLayers_.mesh_.points();
const point v000 = points[seDirI.start()];
const point v100 = points[seDirI.end()];
const point v110 = points[facePoints_[0].lastElement().lastElement()];
const point v110 = points[facePoints_[0].last().last()];
const point v010 = points[seDirJ.end()];
const point v001 = points[seDirK.end()];
const point v101 = points[facePoints_[1].lastElement()[0]];
const point v111 = points[facePoints_[1].lastElement().lastElement()];
const point v011 = points[facePoints_[1][0].lastElement()];
const point v101 = points[facePoints_[1].last()[0]];
const point v111 = points[facePoints_[1].last().last()];
const point v011 = points[facePoints_[1][0].last()];
for (label i = 1; i < nLayersI_; ++i)
{
......@@ -1343,9 +1343,9 @@ void refineBoundaryLayers::refineCornerHexCell::generateMissingFaces()
forAll(f, eI)
{
const edge e(f[eI], f.fcElement(eI));
const edge e(f[eI], f.fcValue(eI));
const label pos = edges.containsAtPosition(e);
const label pos = edges.find(e);
if (pos < 0)
{
......@@ -1954,7 +1954,7 @@ void refineBoundaryLayers::generateNewCells()
{
const edge e = f.faceEdge(eI);
const label pos = edges.containsAtPosition(e);
const label pos = edges.find(e);
if (pos < 0)
{
......
......@@ -1009,7 +1009,7 @@ void refineBoundaryLayers::generateNewFaces()
forAll(currLayers, i)
{
if (neiLayers.contains(currLayers[i]))
if (neiLayers.found(currLayers[i]))
{
foundSame = true;
break;
......
......@@ -172,15 +172,22 @@ public:
//- present in the list (takes linear time)
inline void appendIfNotIn(const T& e);
//- check if the element is in the list (takes linear time)
inline bool contains(const T& e) const;
inline label containsAtPosition(const T& e) const;
//- Find and return location of element in list
inline label find(const T& val) const;
//- Check if the element is in the list
inline bool found(const T& e) const;
//- return a const reference to the first element
inline const T& first() const;
//- return a const reference to the last element
inline const T& lastElement() const;
inline const T& last() const;
//- Return and remove the last element
inline T removeLastElement();
inline T remove();
//- Return and remove the element
inline T removeElement(const label i);
//- return a reference to the element. Resize the list if necessary
......@@ -195,21 +202,12 @@ public:
inline T& operator[](const label);
//- return forward and reverse circular indices
inline label fcIndex(const label index, const label offset = 1) const;
inline label rcIndex(const label index, const label offset = 1) const;
inline label fcIndex(const label index) const;
inline label rcIndex(const label index) const;
//- return forward and reverse circular elements
inline const T& fcElement
(
const label index,
const label offset = 1
) const;
inline const T& rcElement
(
const label index,
const label offset = 1
) const;
inline const T& fcValue(const label index) const;
inline const T& rcValue(const label index) const;
//- Assignment of all entries to the given value
inline void operator=(const T&);
......
......@@ -352,7 +352,7 @@ inline void Foam::DynList<T, staticSize>::appendIfNotIn(const T& e)
checkAllocation();
# endif
if (!contains(e))
if (!found(e))
{
append(e);
}
......@@ -364,7 +364,10 @@ inline void Foam::DynList<T, staticSize>::appendIfNotIn(const T& e)
template<class T, Foam::label staticSize>
inline bool Foam::DynList<T, staticSize>::contains(const T& e) const
inline Foam::label Foam::DynList<T, staticSize>::find
(
const T& e
) const
{
# ifdef DEBUG
checkAllocation();
......@@ -374,38 +377,35 @@ inline bool Foam::DynList<T, staticSize>::contains(const T& e) const
{
if (this->operator[](i) == e)
{
return true;
return i;
}
}
return false;
return -1;
}
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::containsAtPosition
(
const T& e
) const
inline bool Foam::DynList<T, staticSize>::found(const T& e) const
{
return this->find(e) != -1;
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::first() const
{
# ifdef DEBUG
checkAllocation();
# endif
for (label i = 0; i < nextFree_; ++i)
{
if (this->operator[](i) == e)
{
return i;
}
}
return -1;
return this->operator[](0);
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::lastElement() const
inline const T& Foam::DynList<T, staticSize>::last() const
{
# ifdef DEBUG
checkAllocation();
......@@ -416,7 +416,7 @@ inline const T& Foam::DynList<T, staticSize>::lastElement() const
template<class T, Foam::label staticSize>
inline T Foam::DynList<T, staticSize>::removeLastElement()
inline T Foam::DynList<T, staticSize>::remove()
{
# ifdef DEBUG
checkAllocation();
......@@ -521,44 +521,40 @@ inline T& Foam::DynList<T, staticSize>::operator[](const label i)
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::fcIndex
(
const label index,
const label offset
const label index
) const
{
return (index + offset) % nextFree_;
return (index + 1) % nextFree_;
}
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::rcIndex
(
const label index,
const label offset
const label index
) const
{
return (index + nextFree_ - offset) % nextFree_;
return (index + nextFree_ - 1) % nextFree_;
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::fcElement
inline const T& Foam::DynList<T, staticSize>::fcValue
(
const label index,
const label offset
const label index
) const
{
return operator[](fcIndex(index, offset));
return operator[](fcIndex(index));
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::rcElement
inline const T& Foam::DynList<T, staticSize>::rcValue
(
const label index,
const label offset
const label index
) const
{
return operator[](rcIndex(index, offset));
return operator[](rcIndex(index));
}
......
......@@ -139,7 +139,8 @@ public:
//- check if the element is in the given row (takes linear time)
inline bool contains(const label rowI, const T& e) const;
inline label containsAtPosition(const label rowI, const T& e) const;
inline bool found(const label rowI, const T& e) const;
inline label find(const label rowI, const T& e) const;
//- get and set operators
inline const T& operator()(const label i, const label j) const;
......
......@@ -160,22 +160,23 @@ inline bool Foam::FRWGraph<T, width>::contains
const T& e
) const
{
const label start = rowI*width;
return (this->find(rowI, e) >= 0);
}
for (label i = 0; i < width; ++i)
{
if (data_[start + i] == e)
{
return true;
}
}
return false;
template<class T, Foam::label width>
inline bool Foam::FRWGraph<T, width>::found
(
const label rowI,
const T& e
) const
{
return (this->find(rowI, e) >= 0);
}
template<class T, Foam::label width>
inline Foam::label Foam::FRWGraph<T, width>::containsAtPosition
inline Foam::label Foam::FRWGraph<T, width>::find
(
const label rowI,
const T& e
......
......@@ -31,13 +31,8 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T, label Offset>
IOLongList<T, Offset>::IOLongList(const IOobject& io)
template<class T, int Offset>
Foam::IOLongList<T, Offset>::IOLongList(const IOobject& io)
:
regIOobject(io),
LongList<T, Offset>()
......@@ -54,8 +49,8 @@ IOLongList<T, Offset>::IOLongList(const IOobject& io)
}
template<class T, label Offset>
IOLongList<T, Offset>::IOLongList
template<class T, int Offset>
Foam::IOLongList<T, Offset>::IOLongList
(
const IOobject& io,
const label size
......@@ -66,8 +61,8 @@ IOLongList<T, Offset>::IOLongList
{}
template<class T, label Offset>
IOLongList<T, Offset>::IOLongList
template<class T, int Offset>
Foam::IOLongList<T, Offset>::IOLongList
(
const IOobject& io,
const LongList<T, Offset>& list
......@@ -86,8 +81,8 @@ IOLongList<T, Offset>::IOLongList
}
template<class T, label Offset>
void IOLongList<T, Offset>::operator=
template<class T, int Offset>
void Foam::IOLongList<T, Offset>::operator=
(
const IOLongList<T, Offset>& rhs
)
......@@ -96,8 +91,8 @@ void IOLongList<T, Offset>::operator=
}
template<class T, label Offset>
void IOLongList<T, Offset>::operator=
template<class T, int Offset>
void Foam::IOLongList<T, Offset>::operator=
(
const LongList<T, Offset>& rhs
)
......@@ -106,15 +101,11 @@ void IOLongList<T, Offset>::operator=
}
template<class T, label Offset>
bool IOLongList<T, Offset>::writeData(Ostream& os) const
template<class T, int Offset>
bool Foam::IOLongList<T, Offset>::writeData(Ostream& os) const
{
return (os << *this).good();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -48,7 +48,7 @@ namespace Foam
Class IOLongList Declaration
\*---------------------------------------------------------------------------*/
template<class T, label Offset = 19>
template<class T, int Offset = 19>
class IOLongList
:
public regIOobject,
......
......@@ -29,26 +29,23 @@ License
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, Foam::label Offset>
template<class T, int Offset>
void Foam::LongList<T, Offset>::writeEntry(Ostream& os) const
{
if
(
size()
&& token::compound::isCompound
(
"LongList<" + word(pTraits<T>::typeName) + '>'
)
)
if (size())
{
os << word("LongList<" + word(pTraits<T>::typeName) + '>') << " ";
const word tag = "LongList<" + word(pTraits<T>::typeName) + '>';
if (token::compound::isCompound(tag))
{
os << tag << ' ';
}
}
os << *this;
}
template<class T, Foam::label Offset>
template<class T, int Offset>
void Foam::LongList<T, Offset>::writeEntry
(
const word& keyword,
......@@ -61,7 +58,7 @@ void Foam::LongList<T, Offset>::writeEntry
}
template<class T, Foam::label Offset>
template<class T, int Offset>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
......@@ -78,7 +75,7 @@ Foam::Ostream& Foam::operator<<
// Write list contents
forAll(DL, i)
{
if (i != 0) os << token::SPACE;
if (i) os << token::SPACE;
os << DL[i];
}
......@@ -88,16 +85,16 @@ Foam::Ostream& Foam::operator<<
else
{
// Write size of list and start contents delimiter
os << nl << DL.size() << nl << token::BEGIN_LIST;
os << nl << DL.size() << nl << token::BEGIN_LIST << nl;
// Write list contents
forAll(DL, i)
{
os << nl << DL[i];
os << DL[i] << nl;
}
// Write end of contents delimiter
os << nl << token::END_LIST << nl;
os << token::END_LIST << nl;
}
}
else
......@@ -132,7 +129,7 @@ Foam::Ostream& Foam::operator<<
}
template<class T, Foam::label Offset>
template<class T, int Offset>
Foam::Istream& Foam::operator>>
(
Istream& is,
......@@ -148,7 +145,8 @@ Foam::Istream& Foam::operator>>
is.fatalCheck
(
"operator>>(Istream&, LongList<T, Offset>&) : reading first token"
"operator>>(Istream&, LongList<T, Offset>&) : "
"reading first token"
);
if (firstToken.isLabel())
......@@ -192,8 +190,8 @@ Foam::Istream& Foam::operator>>
is.fatalCheck
(
"operator>>(Istream&, LongList<T, Offset>&)"
" : reading entry"
"operator>>(Istream&, LongList<T, Offset>&) : "
"reading entry"
);
}
}
......@@ -204,8 +202,8 @@ Foam::Istream& Foam::operator>>
is.fatalCheck
(
"operator>>(Istream&, LongList<T, Offset>&)"
": reading the single entry"
"operator>>(Istream&, LongList<T, Offset>&) : "
"reading the single entry"
);
for (label i = 0; i < size; ++i)
......@@ -240,8 +238,8 @@ Foam::Istream& Foam::operator>>
is.fatalCheck
(
"operator>>(Istream&, LongList<T, Offset>&)"
": reading the binary block"
"operator>>(Istream&, LongList<T, Offset>&) : "
"reading the binary block"
);
}
}
......@@ -257,7 +255,7 @@ Foam::Istream& Foam::operator>>
}
template<class T, Foam::label Offset>
template<class T, int Offset>
void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
{
is.fatalCheck(FUNCTION_NAME);
......@@ -299,7 +297,8 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
is.fatalCheck
(
"appendFromStream(Istream&) : reading entry"
"appendFromStream(Istream&) : "
"reading entry"
);
}
}
......@@ -310,7 +309,8 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
is.fatalCheck
(
"appendFromStream(Istream&) : reading the single entry"
"appendFromStream(Istream&) : "
"reading the single entry"
);
for (label i = 0; i < size; ++i)
......@@ -335,7 +335,8 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
is.fatalCheck
(
"appendFromStream(Istream&) : reading the binary block"
"appendFromStream(Istream&) : "
"reading the binary block"
);
}
}
......
......@@ -51,17 +51,18 @@ namespace Foam
{
// Forward declaration of template friend functions
class Istream;
class Ostream;
template<class T, label Offset>
class LongList;
template<class T, int Offset> class LongList;
template<class T, label Offset>
template<class T, int Offset>
Ostream& operator<<
(
Ostream&,
const LongList<T, Offset>&
);
template<class T, label Offset>
template<class T, int Offset>