1) Remove the alias itself in arrayref.h.
2) All replacements done automatically using sed:
s#ConstArrayRef<const char \*>#ArrayRef<const char *const>#
s#ConstArrayRef<\(.*\)>#ArrayRef<const \1>#
This worked because "const char*" was the only pointer type used as
template argument.
Change-Id: I5eba895a5dc235b95d77670b4f258e423f64f3b8
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
};
//! Shorthand for reference to an array of data values.
-typedef ConstArrayRef<AnalysisDataValue> AnalysisDataValuesRef;
+typedef ArrayRef<const AnalysisDataValue> AnalysisDataValuesRef;
/*! \brief
};
//! Shorthand for reference to an array of point set data objects.
-typedef ConstArrayRef<AnalysisDataPointSetInfo> AnalysisDataPointSetInfosRef;
+typedef ArrayRef<const AnalysisDataPointSetInfo> AnalysisDataPointSetInfosRef;
//! \endcond
cmdlineContext.setModuleDisplayName(helpModule_.binaryName_);
optionsHolder.initOptions();
Options &options = *optionsHolder.options();
- ConstArrayRef<const char *> helpText;
+ ArrayRef<const char *const> helpText;
if (context.outputFormat() != eHelpOutputFormat_Console)
{
helpText = RootHelpText::text;
//! Help text.
std::string helpText_;
//! List of bugs/knows issues.
- ConstArrayRef<const char *> bugs_;
+ ArrayRef<const char *const> bugs_;
};
void CommandLineHelpWriter::Impl::formatBugs(const HelpWriterContext &context)
return;
}
context.writeTitle("Known Issues");
- ConstArrayRef<const char *>::const_iterator i;
+ ArrayRef<const char *const>::const_iterator i;
for (i = bugs_.begin(); i != bugs_.end(); ++i)
{
const char *const bug = *i;
}
CommandLineHelpWriter &
-CommandLineHelpWriter::setKnownIssues(const ConstArrayRef<const char *> &bugs)
+CommandLineHelpWriter::setKnownIssues(const ArrayRef<const char *const> &bugs)
{
impl_->bugs_ = bugs;
return *this;
const std::string &helpText() const { return helpText_; }
- virtual void setHelpText(const ConstArrayRef<const char *> &help)
+ virtual void setHelpText(const ArrayRef<const char *const> &help)
{
helpText_ = joinStrings(help, "\n");
}
*
* \ingroup module_commandline
*/
-int getDefaultXvgFormat(gmx::ConstArrayRef<const char *> xvgFormats)
+int getDefaultXvgFormat(gmx::ArrayRef<const char *const> xvgFormats)
{
const char *const select = getenv("GMX_VIEW_XVG");
if (select != nullptr)
{
- ConstArrayRef<const char *>::const_iterator i =
+ ArrayRef<const char *const>::const_iterator i =
std::find(xvgFormats.begin(), xvgFormats.end(), std::string(select));
if (i != xvgFormats.end())
{
0, nullptr, 0, nullptr, &oenv_);
EXPECT_TRUE(bOk);
}
- void parseFromArray(gmx::ConstArrayRef<const char *> cmdline,
+ void parseFromArray(gmx::ArrayRef<const char *const> cmdline,
unsigned long flags,
gmx::ArrayRef<t_filenm> fnm,
gmx::ArrayRef<t_pargs> pa)
//! A safe pointer type for PME.
typedef gmx::unique_cptr<gmx_pme_t, gmx_pme_destroy> PmeSafePointer;
//! Charges
-typedef ConstArrayRef<real> ChargesVector;
+typedef ArrayRef<const real> ChargesVector;
//! Coordinates
typedef std::vector<RVec> CoordinatesVector;
//! Forces
typedef ArrayRef<RVec> ForcesVector;
//! Gridline indices
-typedef ConstArrayRef<IVec> GridLineIndicesVector;
+typedef ArrayRef<const IVec> GridLineIndicesVector;
/*! \brief Spline parameters (theta or dtheta).
* A reference to a single dimension's spline data; this means (atomCount * pmeOrder) values or derivatives.
*/
-typedef ConstArrayRef<real> SplineParamsDimVector;
+typedef ArrayRef<const real> SplineParamsDimVector;
/*! \brief Spline parameters (theta or dtheta) in all 3 dimensions
*/
typedef std::array<SplineParamsDimVector, DIM> SplineParamsVector;
//! Return whether the contents of \c a and \c b are the same, considering also reversed order.
template <typename T>
-static bool equalEitherForwardOrBackward(gmx::ConstArrayRef<T> a, gmx::ConstArrayRef<T> b)
+static bool equalEitherForwardOrBackward(gmx::ArrayRef<const T> a, gmx::ArrayRef<const T> b)
{
return (std::equal(a.begin(), a.end(), b.begin()) ||
std::equal(a.begin(), a.end(), b.rbegin()));
bool haveErrored = false;
for (int i = 0; (i < nr); i++)
{
- gmx::ConstArrayRef<int> bParams(b->a, b->a + nral);
- gmx::ConstArrayRef<int> testParams(bt->param[i].a, bt->param[i].a + nral);
+ gmx::ArrayRef<const int> bParams(b->a, b->a + nral);
+ gmx::ArrayRef<const int> testParams(bt->param[i].a, bt->param[i].a + nral);
if (equalEitherForwardOrBackward(bParams, testParams))
{
GMX_ASSERT(nrfp <= MAXFORCEPARAM, "This is ensured in other places, but we need this assert to keep the clang analyzer happy");
}
}
-void sum_dhdl(gmx_enerdata_t *enerd, gmx::ConstArrayRef<real> lambda, t_lambda *fepvals)
+void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda *fepvals)
{
int index;
double dlam;
void sum_epot(gmx_grppairener_t *grpp, real *epot);
/* Locally sum the non-bonded potential energy terms */
-void sum_dhdl(gmx_enerdata_t *enerd, gmx::ConstArrayRef<real> lambda, t_lambda *fepvals);
+void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda *fepvals);
/* Sum the free energy contributions */
/* Compute the average C6 and C12 params for LJ corrections */
rvec *x_old, rvec *x_init, rvec *x,
rvec *f, rvec *acc_dir,
gmx_bool bMolPBC, matrix box,
- gmx::ConstArrayRef<real> lambda, real *dvdlambda,
+ gmx::ArrayRef<const real> lambda, real *dvdlambda,
t_nrnb *nrnb)
{
rvec *xnold, *xnew;
walltime_accounting_get_start_time_stamp(walltime_accounting));
}
-static void sum_forces(rvec f[], gmx::ConstArrayRef<gmx::RVec> forceToAdd)
+static void sum_forces(rvec f[], gmx::ArrayRef<const gmx::RVec> forceToAdd)
{
const int end = forceToAdd.size();
}
checkText(result, id);
}
- void testFormatting(const gmx::ConstArrayRef<const char *> &text)
+ void testFormatting(const gmx::ArrayRef<const char *const> &text)
{
std::string testText = gmx::joinStrings(text, "\n");
testFormatting(testText, gmx::eHelpOutputFormat_Console, nullptr);
}
else
{
- ConstArrayRef<FileTypeMapping> map(c_fileTypeMapping);
- ConstArrayRef<FileTypeMapping>::const_iterator i;
+ ArrayRef<const FileTypeMapping> map(c_fileTypeMapping);
+ ArrayRef<const FileTypeMapping>::const_iterator i;
for (i = map.begin(); i != map.end(); ++i)
{
if (i->optionType == settings.optionType_)
return typeHandler.isValidType(fileType);
}
-ConstArrayRef<int> FileNameOptionStorage::fileTypes() const
+ArrayRef<const int> FileNameOptionStorage::fileTypes() const
{
if (fileType_ < 0)
{
- return ConstArrayRef<int>();
+ return ArrayRef<const int>();
}
const int genericTypeCount = ftp2generic_count(fileType_);
if (genericTypeCount > 0)
return option().isValidType(fileType);
}
-ConstArrayRef<int> FileNameOptionInfo::fileTypes() const
+ArrayRef<const int> FileNameOptionInfo::fileTypes() const
{
return option().fileTypes();
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
const FileNameOptionInfo &option,
const IFileInputRedirector *redirector)
{
- ConstArrayRef<int> types = option.fileTypes();
- ConstArrayRef<int>::const_iterator i;
+ ArrayRef<const int> types = option.fileTypes();
+ ArrayRef<const int>::const_iterator i;
for (i = types.begin(); i != types.end(); ++i)
{
std::string testFilename(prefix + ftp2ext_with_dot(*i));
if (fileType == efNR
&& impl_->redirector_->fileExists(value, File::throwOnError))
{
- ConstArrayRef<const char *> compressedExtensions(c_compressedExtensions);
- ConstArrayRef<const char *>::const_iterator ext;
+ ArrayRef<const char *const> compressedExtensions(c_compressedExtensions);
+ ArrayRef<const char *const>::const_iterator ext;
for (ext = compressedExtensions.begin(); ext != compressedExtensions.end(); ++ext)
{
if (endsWith(value, *ext))
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
//! \copydoc FileNameOptionInfo::isValidType()
bool isValidType(int fileType) const;
//! \copydoc FileNameOptionInfo::fileTypes()
- ConstArrayRef<int> fileTypes() const;
+ ArrayRef<const int> fileTypes() const;
private:
virtual void initConverter(ConverterType *converter);
* The non-const variant should only be used from processAll() in
* derived classes if necessary.
*/
- ArrayRef<T> values() { return store_->values(); }
+ ArrayRef<T> values() { return store_->values(); }
//! Provides derived classes access to the current list of values.
- ConstArrayRef<T> values() const { return store_->values(); }
+ ArrayRef<const T> values() const { return store_->values(); }
private:
//! Creates the internal storage object for final values..
const char *const value = std::getenv("GMXTIMEUNIT");
if (value != nullptr)
{
- ConstArrayRef<const char *> timeUnits(g_timeUnits);
- ConstArrayRef<const char *>::const_iterator i =
+ ArrayRef<const char *const> timeUnits(g_timeUnits);
+ ArrayRef<const char *const>::const_iterator i =
std::find(timeUnits.begin(), timeUnits.end(), std::string(value));
if (i == timeUnits.end())
{
* AnalysisNeighborhood::setTopologyExclusions().
*/
AnalysisNeighborhoodPositions &
- exclusionIds(ConstArrayRef<int> ids)
+ exclusionIds(ArrayRef<const int> ids)
{
GMX_ASSERT(static_cast<int>(ids.size()) == count_,
"Exclusion id array should match the number of positions");
* indices to the \p indices array passed here.
*/
AnalysisNeighborhoodPositions &
- indexed(ConstArrayRef<int> indices)
+ indexed(ArrayRef<const int> indices)
{
count_ = indices.size();
indices_ = indices.data();
* there are also other thread-unsafe constructs here), so a temporary
* array is used to avoid repeated memory allocation.
*/
- ConstArrayRef<int> getFrameIndices(int size, int index[])
+ ArrayRef<const int> getFrameIndices(int size, int index[])
{
if (mapToFrameAtoms_.empty())
{
clear_rvec(p->f[i]);
}
}
- gmx::ConstArrayRef<int> index = pc->coll->getFrameIndices(pc->b.nra, pc->b.a);
- const gmx_mtop_t *top = pc->coll->top_;
- const bool bMass = pc->flags & POS_MASS;
+ gmx::ArrayRef<const int> index = pc->coll->getFrameIndices(pc->b.nra, pc->b.a);
+ const gmx_mtop_t *top = pc->coll->top_;
+ const bool bMass = pc->flags & POS_MASS;
switch (pc->type)
{
case POS_ATOM:
return data().rawPositions_.m.mapb.nra;
}
//! Returns atom indices of all atoms in the selection.
- ConstArrayRef<int> atomIndices() const
+ ArrayRef<const int> atomIndices() const
{
return constArrayRefFromArray(sel_->rawPositions_.m.mapb.a,
sel_->rawPositions_.m.mapb.nra);
//! Access a single position.
SelectionPosition position(int i) const;
//! Returns coordinates for this selection as a continuous array.
- ConstArrayRef<rvec> coordinates() const
+ ArrayRef<const rvec> coordinates() const
{
return constArrayRefFromArray(data().rawPositions_.x, posCount());
}
*
* Must not be called if hasVelocities() returns false.
*/
- ConstArrayRef<rvec> velocities() const
+ ArrayRef<const rvec> velocities() const
{
GMX_ASSERT(hasVelocities(), "Velocities accessed, but unavailable");
return constArrayRefFromArray(data().rawPositions_.v, posCount());
*
* Must not be called if hasForces() returns false.
*/
- ConstArrayRef<rvec> forces() const
+ ArrayRef<const rvec> forces() const
{
GMX_ASSERT(hasForces(), "Forces accessed, but unavailable");
return constArrayRefFromArray(data().rawPositions_.f, posCount());
}
//! Returns masses for this selection as a continuous array.
- ConstArrayRef<real> masses() const
+ ArrayRef<const real> masses() const
{
// posMass_ may have more entries than posCount() in the case of
// dynamic selections that don't have a topology
data().posMass_.begin() + posCount());
}
//! Returns charges for this selection as a continuous array.
- ConstArrayRef<real> charges() const
+ ArrayRef<const real> charges() const
{
// posCharge_ may have more entries than posCount() in the case of
// dynamic selections that don't have a topology
*
* \see SelectionPosition::refId()
*/
- ConstArrayRef<int> refIds() const
+ ArrayRef<const int> refIds() const
{
return constArrayRefFromArray(data().rawPositions_.m.refid, posCount());
}
*
* \see SelectionPosition::mappedId()
*/
- ConstArrayRef<int> mappedIds() const
+ ArrayRef<const int> mappedIds() const
{
return constArrayRefFromArray(data().rawPositions_.m.mapid, posCount());
}
- sel_->rawPositions_.m.mapb.index[i_];
}
//! Return atom indices that make up this position.
- ConstArrayRef<int> atomIndices() const
+ ArrayRef<const int> atomIndices() const
{
const int *atoms = sel_->rawPositions_.m.mapb.a;
if (atoms == nullptr)
{
- return ConstArrayRef<int>();
+ return ArrayRef<const int>();
}
const int first = sel_->rawPositions_.m.mapb.index[i_];
return constArrayRefFromArray(&atoms[first], atomCount());
const t_blocka *exclusions() const { return &excls_; }
- gmx::ConstArrayRef<int> refPosIds() const
+ gmx::ArrayRef<const int> refPosIds() const
{
return gmx::constArrayRefFromVector<int>(exclusionIds_.begin(),
exclusionIds_.begin() + refPosCount_);
}
- gmx::ConstArrayRef<int> testPosIds() const
+ gmx::ArrayRef<const int> testPosIds() const
{
return gmx::constArrayRefFromVector<int>(exclusionIds_.begin(),
exclusionIds_.begin() + testPosCount_);
const NeighborhoodSearchTestData &data,
const gmx::AnalysisNeighborhoodPositions &pos,
const t_blocka *excls,
- const gmx::ConstArrayRef<int> &refIndices,
- const gmx::ConstArrayRef<int> &testIndices,
+ const gmx::ArrayRef<const int> &refIndices,
+ const gmx::ArrayRef<const int> &testIndices,
bool selfPairs);
gmx::AnalysisNeighborhood nb_;
const NeighborhoodSearchTestData &data,
const gmx::AnalysisNeighborhoodPositions &pos,
const t_blocka *excls,
- const gmx::ConstArrayRef<int> &refIndices,
- const gmx::ConstArrayRef<int> &testIndices,
+ const gmx::ArrayRef<const int> &refIndices,
+ const gmx::ArrayRef<const int> &testIndices,
bool selfPairs)
{
std::map<int, RefPairList> refPairs;
void generateCoordinates();
gmx_ana_poscalc_t *createCalculation(e_poscalc_t type, int flags);
- void setMaximumGroup(gmx_ana_poscalc_t *pc, const gmx::ConstArrayRef<int> &atoms);
+ void setMaximumGroup(gmx_ana_poscalc_t *pc, const gmx::ArrayRef<const int> &atoms);
gmx_ana_pos_t *initPositions(gmx_ana_poscalc_t *pc, const char *name);
void checkInitialized();
void updateAndCheck(gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p,
- const gmx::ConstArrayRef<int> &atoms,
+ const gmx::ArrayRef<const int> &atoms,
gmx::test::TestReferenceChecker *checker,
const char *name);
void testSingleStatic(e_poscalc_t type, int flags, bool bExpectTop,
- const gmx::ConstArrayRef<int> &atoms,
- const gmx::ConstArrayRef<int> &index = gmx::EmptyArrayRef());
+ const gmx::ArrayRef<const int> &atoms,
+ const gmx::ArrayRef<const int> &index = gmx::EmptyArrayRef());
void testSingleDynamic(e_poscalc_t type, int flags, bool bExpectTop,
- const gmx::ConstArrayRef<int> &initAtoms,
- const gmx::ConstArrayRef<int> &evalAtoms,
- const gmx::ConstArrayRef<int> &index = gmx::EmptyArrayRef());
+ const gmx::ArrayRef<const int> &initAtoms,
+ const gmx::ArrayRef<const int> &evalAtoms,
+ const gmx::ArrayRef<const int> &index = gmx::EmptyArrayRef());
gmx::test::TestReferenceData data_;
gmx::test::TestReferenceChecker checker_;
return pcList_.back();
}
-void PositionCalculationTest::setMaximumGroup(gmx_ana_poscalc_t *pc,
- const gmx::ConstArrayRef<int> &atoms)
+void PositionCalculationTest::setMaximumGroup(gmx_ana_poscalc_t *pc,
+ const gmx::ArrayRef<const int> &atoms)
{
setTopologyIfRequired();
gmx_ana_index_t g;
}
void PositionCalculationTest::updateAndCheck(
- gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p, const gmx::ConstArrayRef<int> &atoms,
+ gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p, const gmx::ArrayRef<const int> &atoms,
gmx::test::TestReferenceChecker *checker, const char *name)
{
gmx_ana_index_t g;
void PositionCalculationTest::testSingleStatic(
e_poscalc_t type, int flags, bool bExpectTop,
- const gmx::ConstArrayRef<int> &atoms,
- const gmx::ConstArrayRef<int> &index)
+ const gmx::ArrayRef<const int> &atoms,
+ const gmx::ArrayRef<const int> &index)
{
t_trxframe *frame = topManager_.frame();
if (frame->bV)
void PositionCalculationTest::testSingleDynamic(
e_poscalc_t type, int flags, bool bExpectTop,
- const gmx::ConstArrayRef<int> &initAtoms,
- const gmx::ConstArrayRef<int> &evalAtoms,
- const gmx::ConstArrayRef<int> &index)
+ const gmx::ArrayRef<const int> &initAtoms,
+ const gmx::ArrayRef<const int> &evalAtoms,
+ const gmx::ArrayRef<const int> &index)
{
gmx_ana_poscalc_t *pc = createCalculation(type, flags | POS_DYNAMIC);
const bool requiresTopology
}
void runTest(int count, bool bInteractive,
- const gmx::ConstArrayRef<const char *> &input);
+ const gmx::ArrayRef<const char *const> &input);
gmx::test::TestReferenceData data_;
gmx::test::InteractiveTestHelper helper_;
void SelectionCollectionInteractiveTest::runTest(
int count, bool bInteractive,
- const gmx::ConstArrayRef<const char *> &inputLines)
+ const gmx::ArrayRef<const char *const> &inputLines)
{
helper_.setInputLines(inputLines);
// TODO: Check something about the returned selections as well.
void setFlags(TestFlags flags) { flags_ = flags; }
- void runParser(const gmx::ConstArrayRef<const char *> &selections);
+ void runParser(const gmx::ArrayRef<const char *const> &selections);
void runCompiler();
void runEvaluate();
void runEvaluateFinal();
void runTest(int natoms,
- const gmx::ConstArrayRef<const char *> &selections);
+ const gmx::ArrayRef<const char *const> &selections);
void runTest(const char *filename,
- const gmx::ConstArrayRef<const char *> &selections);
+ const gmx::ArrayRef<const char *const> &selections);
private:
static void checkSelection(gmx::test::TestReferenceChecker *checker,
using gmx::test::TestReferenceChecker;
{
- gmx::ConstArrayRef<int> atoms = sel.atomIndices();
+ gmx::ArrayRef<const int> atoms = sel.atomIndices();
checker->checkSequence(atoms.begin(), atoms.end(), "Atoms");
}
if (flags.test(efTestPositionAtoms)
const gmx::SelectionPosition &p = sel.position(i);
if (flags.test(efTestPositionAtoms))
{
- gmx::ConstArrayRef<int> atoms = p.atomIndices();
+ gmx::ArrayRef<const int> atoms = p.atomIndices();
poscompound.checkSequence(atoms.begin(), atoms.end(), "Atoms");
}
if (flags.test(efTestPositionCoordinates))
void
SelectionCollectionDataTest::runParser(
- const gmx::ConstArrayRef<const char *> &selections)
+ const gmx::ArrayRef<const char *const> &selections)
{
using gmx::test::TestReferenceChecker;
void
SelectionCollectionDataTest::runTest(
- int natoms, const gmx::ConstArrayRef<const char *> &selections)
+ int natoms, const gmx::ArrayRef<const char *const> &selections)
{
ASSERT_NO_FATAL_FAILURE(runParser(selections));
ASSERT_NO_FATAL_FAILURE(setAtomCount(natoms));
void
SelectionCollectionDataTest::runTest(
- const char *filename, const gmx::ConstArrayRef<const char *> &selections)
+ const char *filename, const gmx::ArrayRef<const char *const> &selections)
{
ASSERT_NO_FATAL_FAILURE(runParser(selections));
ASSERT_NO_FATAL_FAILURE(loadTopology(filename));
}
}
-void TopologyManager::initAtomTypes(const ConstArrayRef<const char *> &types)
+void TopologyManager::initAtomTypes(const ArrayRef<const char *const> &types)
{
GMX_RELEASE_ASSERT(mtop_ != nullptr, "Topology not initialized");
atomtypes_.reserve(types.size());
mtop_->mols.index[mtop_->mols.nr] = mtop_->natoms;
}
-void TopologyManager::initFrameIndices(const ConstArrayRef<int> &index)
+void TopologyManager::initFrameIndices(const ArrayRef<const int> &index)
{
GMX_RELEASE_ASSERT(frame_ != nullptr, "Frame not initialized");
GMX_RELEASE_ASSERT(!frame_->bIndex, "Frame atom indices can only be set once");
EXPECT_TRUE(empty.empty());
}
-TEST(EmptyConstArrayRefTest, IsEmpty)
-{
- EmptyArrayRef emptyArray = {};
- ConstArrayRef<SimdReal> empty(emptyArray);
-
- EXPECT_EQ(0U, empty.size());
- EXPECT_TRUE(empty.empty());
-}
-
#ifdef GTEST_HAS_TYPED_TEST
/*! \brief Permit all the tests to run on all kinds of ArrayRefs
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \param[out] yfghTableData Output cubic spline table with Y,F,G,H entries
*/
void
-fillSingleCubicSplineTableData(ConstArrayRef<double> function,
- ConstArrayRef<double> derivative,
+fillSingleCubicSplineTableData(ArrayRef<const double> function,
+ ArrayRef<const double> derivative,
double inputSpacing,
const std::pair<real, real> &range,
double spacing,
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \param[out] derivativeTableData OUtput table with (adjusted) derivative data
*/
void
-fillSingleQuadraticSplineTableData(ConstArrayRef<double> function,
- ConstArrayRef<double> derivative,
+fillSingleQuadraticSplineTableData(ArrayRef<const double> function,
+ ArrayRef<const double> derivative,
double inputSpacing,
const std::pair<real, real> &range,
double spacing,
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
void
-throwUnlessDerivativeIsConsistentWithFunction(ConstArrayRef<double> function,
- ConstArrayRef<double> derivative,
+throwUnlessDerivativeIsConsistentWithFunction(ArrayRef<const double> function,
+ ArrayRef<const double> derivative,
double inputSpacing,
const std::pair<real, real> &range)
{
real
-findSmallestQuotientOfFunctionAndSecondDerivative(ConstArrayRef<double> function,
+findSmallestQuotientOfFunctionAndSecondDerivative(ArrayRef<const double> function,
double inputSpacing,
const std::pair<real, real> &range)
{
real
-findSmallestQuotientOfFunctionAndThirdDerivative(ConstArrayRef<double> function,
+findSmallestQuotientOfFunctionAndThirdDerivative(ArrayRef<const double> function,
double inputSpacing,
const std::pair<real, real> &range)
{
std::vector<double>
-vectorSecondDerivative(ConstArrayRef<double> f, double spacing)
+vectorSecondDerivative(ArrayRef<const double> f, double spacing)
{
if (f.size() < 5)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* to avoid accuracy loss.
*/
void
-throwUnlessDerivativeIsConsistentWithFunction(ConstArrayRef<double> function,
- ConstArrayRef<double> derivative,
+throwUnlessDerivativeIsConsistentWithFunction(ArrayRef<const double> function,
+ ArrayRef<const double> derivative,
double inputSpacing,
const std::pair<real, real> &range);
* avoid accuracy loss.
*/
real
-findSmallestQuotientOfFunctionAndSecondDerivative(ConstArrayRef<double> function,
+findSmallestQuotientOfFunctionAndSecondDerivative(ArrayRef<const double> function,
double inputSpacing,
const std::pair<real, real> &range);
* avoid accuracy loss.
*/
real
-findSmallestQuotientOfFunctionAndThirdDerivative(ConstArrayRef<double> function,
+findSmallestQuotientOfFunctionAndThirdDerivative(ArrayRef<const double> function,
double inputSpacing,
const std::pair<real, real> &range);
* accuracy loss (since differentiation can be numerically fragile).
*/
std::vector<double>
-vectorSecondDerivative(ConstArrayRef<double> f,
+vectorSecondDerivative(ArrayRef<const double> f,
double spacing);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
NumericalSplineTableInput
{
const std::string &desc; //!< \libinternal Brief description of function
- ConstArrayRef<double> function; //!< \libinternal Vector with function values
- ConstArrayRef<double> derivative; //!< \libinternal Vector with derivative values
+ ArrayRef<const double> function; //!< \libinternal Vector with function values
+ ArrayRef<const double> derivative; //!< \libinternal Vector with derivative values
double spacing; //!< \libinternal Distance between data points
};
}
void
-TrajectoryAnalysisSettings::setHelpText(const ConstArrayRef<const char *> &help)
+TrajectoryAnalysisSettings::setHelpText(const ArrayRef<const char *const> &help)
{
GMX_RELEASE_ASSERT(impl_->optionsModuleSettings_ != nullptr,
"setHelpText() called in invalid context");
nmol_ = top.topology()->mols.nr;
// Loop over atoms in the selection using an iterator
- const int maxnovdw = 10;
- ConstArrayRef<int> atomind = sel_.atomIndices();
- for (ConstArrayRef<int>::iterator ai = atomind.begin(); (ai < atomind.end()); ++ai)
+ const int maxnovdw = 10;
+ ArrayRef<const int> atomind = sel_.atomIndices();
+ for (ArrayRef<const int>::iterator ai = atomind.begin(); (ai < atomind.end()); ++ai)
{
// Dereference the iterator to obtain an atom number
int i = *ai;
// TODO: Not exception-safe, but nice solution would be to have a C++
// atom properties class...
- gmx_atomprop_t aps = gmx_atomprop_init();
+ gmx_atomprop_t aps = gmx_atomprop_init();
- ConstArrayRef<int> atomIndices = surfaceSel_.atomIndices();
- int ndefault = 0;
+ ArrayRef<const int> atomIndices = surfaceSel_.atomIndices();
+ int ndefault = 0;
for (int i = 0; i < surfaceSel_.posCount(); i++)
{
const int ii = atomIndices[i];
// and store it in the selection ID map for easy lookup.
for (size_t g = 0; g < outputSel_.size(); ++g)
{
- ConstArrayRef<int> outputIndices = outputSel_[g].atomIndices();
+ ArrayRef<const int> outputIndices = outputSel_[g].atomIndices();
for (int i = 0, j = 0; i < outputSel_[g].posCount(); ++i)
{
while (j < surfaceSel_.posCount() && outputIndices[i] > atomIndices[j])
{
for (int i = 0; i < sel_[g].posCount(); ++i)
{
- ConstArrayRef<int> atomIndices
+ ArrayRef<const int> atomIndices
= sel_[g].position(i).atomIndices();
- ConstArrayRef<int>::const_iterator ai;
+ ArrayRef<const int>::const_iterator ai;
for (ai = atomIndices.begin(); ai != atomIndices.end(); ++ai)
{
pdbinfo[*ai].occup += occupancyModule_->average(g, i);
std::set<int> atomIndicesSet;
for (size_t g = 0; g < sel_.size(); ++g)
{
- ConstArrayRef<int> atomIndices = sel_[g].atomIndices();
+ ArrayRef<const int> atomIndices = sel_[g].atomIndices();
atomIndicesSet.insert(atomIndices.begin(), atomIndices.end());
}
std::vector<int> allAtomIndices(atomIndicesSet.begin(),
}
static void
-nsc_dclm_pbc(const rvec *coords, const ConstArrayRef<real> &radius, int nat,
+nsc_dclm_pbc(const rvec *coords, const ArrayRef<const real> &radius, int nat,
const real *xus, int n_dot, int mode,
real *value_of_area, real **at_area,
real *value_of_vol,
}
std::vector<real> unitSphereDots_;
- ConstArrayRef<real> radius_;
+ ArrayRef<const real> radius_;
int flags_;
mutable AnalysisNeighborhood nb_;
};
impl_->unitSphereDots_ = make_unsp(dotCount, 4);
}
-void SurfaceAreaCalculator::setRadii(const ConstArrayRef<real> &radius)
+void SurfaceAreaCalculator::setRadii(const ArrayRef<const real> &radius)
{
impl_->radius_ = radius;
if (!radius.empty())
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* Does not throw.
*/
- void setRadii(const ConstArrayRef<real> &radius);
+ void setRadii(const ArrayRef<const real> &radius);
/*! \brief
* Requests calculation of volume.
* If multiple indices are the same, then these items are considered
* equivalent.
*/
- void initWithGroupIndices(ConstArrayRef<int> indices)
+ void initWithGroupIndices(ArrayRef<const int> indices)
{
mapping_.clear();
int groupCount = 0;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
{
n = nmaxind_;
}
- ConstArrayRef<int> atoms = sel.atomIndices();
+ ArrayRef<const int> atoms = sel.atomIndices();
for (int i = 0; i < n; ++i)
{
fprintf(stderr, " %d", atoms[i]+1);
pointer end_;
};
-
-//! Alias for ArrayRef<const T>
-//! \related ArrayRef
-template <typename T>
-using ConstArrayRef = ArrayRef<const T>;
-
-
//! \copydoc ArrayRef::fromPointers()
//! \related ArrayRef
template <typename T>
//! \copydoc ArrayRef::fromPointers()
//! \related ArrayRef
template <typename T>
-ConstArrayRef<T> constArrayRefFromPointers(const T *begin, const T *end)
+ArrayRef<const T> constArrayRefFromPointers(const T *begin, const T *end)
{
- return ConstArrayRef<T>::fromPointers(begin, end);
+ return ArrayRef<const T>::fromPointers(begin, end);
}
//! \copydoc ArrayRef::fromArray()
//! \related ArrayRef
template <typename T>
-ConstArrayRef<T> constArrayRefFromArray(const T *begin, size_t size)
+ArrayRef<const T> constArrayRefFromArray(const T *begin, size_t size)
{
- return ConstArrayRef<T>::fromArray(begin, size);
+ return ArrayRef<const T>::fromArray(begin, size);
}
//! \copydoc ArrayRef::fromVector()
//! \related ArrayRef
template <typename T>
-ConstArrayRef<T> constArrayRefFromVector(typename std::vector<T>::const_iterator begin,
- typename std::vector<T>::const_iterator end)
+ArrayRef<const T> constArrayRefFromVector(typename std::vector<T>::const_iterator begin,
+ typename std::vector<T>::const_iterator end)
{
- return ConstArrayRef<T>::fromVector(begin, end);
+ return ArrayRef<const T>::fromVector(begin, end);
}
/*! \brief
//! Return a valid random index into \c arrayRef
template <typename T>
-const T &getRandomElement(gmx::ConstArrayRef<T> arrayRef)
+const T &getRandomElement(gmx::ArrayRef<const T> arrayRef)
{
std::random_device generator;
std::uniform_int_distribution<size_t> distribution(0, arrayRef.size()-1);
TEST(EmptyConstArrayRefTest, IsEmpty)
{
- EmptyArrayRef emptyArray = {};
- ConstArrayRef<real> empty(emptyArray);
+ EmptyArrayRef emptyArray = {};
+ ArrayRef<const real> empty(emptyArray);
EXPECT_EQ(0U, empty.size());
EXPECT_TRUE(empty.empty());
ArrayRef<gmx_uint64_t>,
ArrayRef<float>,
ArrayRef<double>,
- ConstArrayRef<char>,
- ConstArrayRef<unsigned char>,
- ConstArrayRef<int>,
- ConstArrayRef<unsigned int>,
- ConstArrayRef<long>,
- ConstArrayRef<unsigned long>,
- ConstArrayRef<gmx_int64_t>,
- ConstArrayRef<gmx_uint64_t>,
- ConstArrayRef<float>,
- ConstArrayRef<double>
+ ArrayRef<const char>,
+ ArrayRef<const unsigned char>,
+ ArrayRef<const int>,
+ ArrayRef<const unsigned int>,
+ ArrayRef<const long>,
+ ArrayRef<const unsigned long>,
+ ArrayRef<const gmx_int64_t>,
+ ArrayRef<const gmx_uint64_t>,
+ ArrayRef<const float>,
+ ArrayRef<const double>
> ArrayRefTypes;
/*! \brief Permit all the tests to run on all kinds of ArrayRefs
{
const char * const words[] = { "The", "quick", "brown", "fox" };
EXPECT_EQ("The .quick .brown .fox ",
- gmx::formatAndJoin(gmx::ConstArrayRef<const char *>(words), ".",
+ gmx::formatAndJoin(gmx::ArrayRef<const char *const>(words), ".",
gmx::StringFormatter("%-10s")));
const int values[] = { 0, 1, 4 };
- EXPECT_EQ("0,1,4", gmx::formatAndJoin(gmx::ConstArrayRef<int>(values), ",",
+ EXPECT_EQ("0,1,4", gmx::formatAndJoin(gmx::ArrayRef<const int>(values), ",",
gmx::StringFormatter("%d")));
}
TEST(JoinStringsTest, Works)
{
const char * const words[] = { "The", "quick", "brown", "fox" };
- gmx::ConstArrayRef<const char *> refToWords(words);
+ gmx::ArrayRef<const char *const> refToWords(words);
EXPECT_EQ("The; quick; brown; fox", gmx::joinStrings(refToWords.begin(), refToWords.end(), "; "));
EXPECT_EQ("The-quick-brown-fox", gmx::joinStrings(refToWords, "-"));
EXPECT_EQ("The-quick-brown-fox", gmx::joinStrings(words, "-"));
{
}
-CommandLine::CommandLine(const ConstArrayRef<const char *> &cmdline)
+CommandLine::CommandLine(const ArrayRef<const char *const> &cmdline)
: impl_(new Impl(cmdline.data(), cmdline.size()))
{
}
{
}
-void CommandLine::initFromArray(const ConstArrayRef<const char *> &cmdline)
+void CommandLine::initFromArray(const ArrayRef<const char *const> &cmdline)
{
impl_.reset(new Impl(cmdline.data(), cmdline.size()));
}
void CommandLineTestHelper::setInputFileContents(
CommandLine *args, const char *option, const char *extension,
- const ConstArrayRef<const char *> &contents)
+ const ArrayRef<const char *const> &contents)
{
GMX_ASSERT(extension[0] != '.', "Extension should not contain a dot");
std::string fullFilename = impl_->fileManager_.getTemporaryFilePath(
formatString("%d.%s", args->argc(), extension));
TextWriter file(fullFilename);
- ConstArrayRef<const char *>::const_iterator i;
+ ArrayRef<const char *const>::const_iterator i;
for (i = contents.begin(); i != contents.end(); ++i)
{
file.writeLine(*i);
void CommandLineTestBase::setInputFileContents(
const char *option, const char *extension,
- const ConstArrayRef<const char *> &contents)
+ const ArrayRef<const char *const> &contents)
{
impl_->helper_.setInputFileContents(&impl_->cmdline_, option, extension,
contents);
* This constructor is not explicit to make it possible to create a
* CommandLine object directly from a C array.
*/
- CommandLine(const ConstArrayRef<const char *> &cmdline);
+ CommandLine(const ArrayRef<const char *const> &cmdline);
//! Creates a deep copy of a command-line object.
CommandLine(const CommandLine &other);
~CommandLine();
*
* Strong exception safety.
*/
- void initFromArray(const ConstArrayRef<const char *> &cmdline);
+ void initFromArray(const ArrayRef<const char *const> &cmdline);
/*! \brief
* Appends an argument to the command line.
*/
void setInputFileContents(CommandLine *args, const char *option,
const char *extension,
- const ConstArrayRef<const char *> &contents);
+ const ArrayRef<const char *const> &contents);
/*! \brief
* Sets an output file parameter and adds it to the set of tested files.
*
*/
void setInputFileContents(const char *option,
const char *extension,
- const ConstArrayRef<const char *> &contents);
+ const ArrayRef<const char *const> &contents);
/*! \brief
* Sets an output file parameter and adds it to the set of tested files.
*
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
}
TestReferenceChecker checker_;
- ConstArrayRef<const char *> inputLines_;
+ ArrayRef<const char *const> inputLines_;
bool bLastNewline_;
size_t currentLine_;
bool bHasOutput_;
}
void InteractiveTestHelper::setInputLines(
- const ConstArrayRef<const char *> &inputLines)
+ const ArrayRef<const char *const> &inputLines)
{
impl_->inputLines_ = inputLines;
impl_->currentLine_ = 0;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* If there are more `readLine()` calls than there are input lines,
* the remaining calls return end-of-input.
*/
- void setInputLines(const ConstArrayRef<const char *> &inputLines);
+ void setInputLines(const ArrayRef<const char *const> &inputLines);
//! Returns the input stream for the session.
TextInputStream &inputStream();