Commit 7d30766d authored by Mark Olesen's avatar Mark Olesen
Browse files

consistency update BiIndirectList, IndirectList

- allow construct with Xfer container for the addressing

- Replaced non-const addressing() method in BiIndirectList with
  resetAddressing() method as per IndirectList
parent 330a1200
......@@ -43,6 +43,10 @@ int main(int argc, char *argv[])
completeList[i] = 0.1*i;
}
Info<< "raw : " << completeList << nl
<< endl;
List<label> addresses(5);
addresses[0] = 1;
addresses[1] = 0;
......@@ -52,14 +56,23 @@ int main(int argc, char *argv[])
IndirectList<double> idl(completeList, addresses);
forAll(idl, i)
{
Info<< idl[i] << token::SPACE;
}
Info<< "addr: " << idl.addressing() << nl
<< "list: " << idl() << nl
<< endl;
addresses[4] = 1;
addresses[3] = 0;
addresses[2] = 7;
addresses[1] = 8;
addresses[0] = 5;
idl.resetAddressing(addresses.xfer());
Info<< endl;
Info<< "addr: " << idl.addressing() << nl
<< "list: " << idl() << nl
<< endl;
Info << "\nEnd\n" << endl;
Info << "End\n" << endl;
return 0;
}
......
......@@ -69,6 +69,14 @@ public:
const UList<label>&
);
//- Construct given the complete list and by transferring addressing
inline BiIndirectList
(
const UList<T>& posList,
const UList<T>& negList,
const Xfer< List<label> >&
);
// Member Functions
......@@ -80,12 +88,17 @@ public:
inline const UList<T>& posList() const;
inline const UList<T>& negList() const;
inline const List<label>& addressing() const;
inline List<label>& addressing();
//- Calculate index given whether index is into posList or negList
inline static label posIndex(const label);
inline static label negIndex(const label);
// Edit
//- Reset addressing
inline void resetAddressing(const UList<label>&);
inline void resetAddressing(const Xfer< List<label> >&);
// Member Operators
......
......@@ -40,6 +40,20 @@ inline Foam::BiIndirectList<T>::BiIndirectList
{}
template<class T>
inline Foam::BiIndirectList<T>::BiIndirectList
(
const UList<T>& posList,
const UList<T>& negList,
const Xfer< List<label> >& addr
)
:
posList_(const_cast<UList<T>&>(posList)),
negList_(const_cast<UList<T>&>(negList)),
addressing_(addr)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
......@@ -79,9 +93,22 @@ inline const Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
template<class T>
inline Foam::List<Foam::label>& Foam::BiIndirectList<T>::addressing()
inline void Foam::BiIndirectList<T>::resetAddressing
(
const UList<label>& addr
)
{
return addressing_;
addressing_ = addr;
}
template<class T>
inline void Foam::BiIndirectList<T>::resetAddressing
(
const Xfer< List<label> >& addr
)
{
addressing_.transfer(addr());
}
......
......@@ -63,6 +63,8 @@ public:
//- Construct given the complete list and the addressing array
inline IndirectList(const UList<T>&, const UList<label>&);
//- Construct given the complete list and by transferring addressing
inline IndirectList(const UList<T>&, const Xfer< List<label> >&);
// Member Functions
......@@ -77,7 +79,8 @@ public:
// Edit
//- Reset addressing
void resetAddressing(const UList<label>&);
inline void resetAddressing(const UList<label>&);
inline void resetAddressing(const Xfer< List<label> >&);
// Member Operators
......
......@@ -38,6 +38,18 @@ inline Foam::IndirectList<T>::IndirectList
{}
template<class T>
inline Foam::IndirectList<T>::IndirectList
(
const UList<T>& completeList,
const Xfer< List<label> >& addr
)
:
completeList_(const_cast<UList<T>&>(completeList)),
addressing_(addr)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
......@@ -78,6 +90,16 @@ inline void Foam::IndirectList<T>::resetAddressing
}
template<class T>
inline void Foam::IndirectList<T>::resetAddressing
(
const Xfer< List<label> >& addr
)
{
addressing_.transfer(addr());
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment