Check frame atom count before evaluating selections
[alexxy/gromacs.git] / src / gromacs / selection / indexutil.cpp
index 3ed8c8783e99020e382325d528546265396e4c61..ad377e9b61b5655d8a71de5010dda5e6be8c1ea7 100644 (file)
@@ -44,6 +44,7 @@
 #include <cstdlib>
 #include <cstring>
 
+#include <algorithm>
 #include <string>
 #include <vector>
 
@@ -420,6 +421,19 @@ gmx_ana_index_dump(FILE *fp, gmx_ana_index_t *g, int maxn)
     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,