* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_selection
*/
-#include "gromacs/selection/indexutil.h"
+#include "gmxpre.h"
+#include "indexutil.h"
+
+#include <cstdlib>
#include <cstring>
+#include <algorithm>
#include <string>
#include <vector>
-#include "gromacs/legacyheaders/index.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
-#include "gromacs/legacyheaders/typedefs.h"
-
+#include "gromacs/topology/block.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/topology/topology.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
/********************************************************************
int n = find_group(const_cast<char *>(name), src->nr,
const_cast<char **>(names));
sfree(names);
- if (n == NOTSET)
+ if (n < 0)
{
dest->isize = 0;
return false;
fprintf(fp, "\n");
}
+int
+gmx_ana_index_get_max_index(gmx_ana_index_t *g)
+{
+ if (g->isize == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return *std::max_element(g->index, g->index + g->isize);
+ }
+}
+
/*!
* \param[in] g Index group to check.
* \returns true if the index group is sorted and has no duplicates,
return true;
}
+bool
+gmx_ana_index_check_range(gmx_ana_index_t *g, int natoms)
+{
+ for (int i = 0; i < g->isize; ++i)
+ {
+ if (g->index[i] < 0 || g->index[i] >= natoms)
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
/********************************************************************
* Set operations
********************************************************************/
void
gmx_ana_index_sort(gmx_ana_index_t *g)
{
- qsort(g->index, g->isize, sizeof(*g->index), cmp_atomid);
+ std::qsort(g->index, g->isize, sizeof(*g->index), cmp_atomid);
}
/*!
break;
default: /* Should not be reached */
- gmx_bug("internal error");
+ GMX_RELEASE_ASSERT(false, "Unreachable code was reached");
break;
}
}