Change ConstArrayRef constructor argument order.
authorTeemu Murtola <teemu.murtola@gmail.com>
Sat, 9 Feb 2013 04:45:32 +0000 (06:45 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 13 Feb 2013 21:27:21 +0000 (22:27 +0100)
The new order is more consistent with STL: e.g., std::copy_n() has
arguments in this order.

Change-Id: I72b8e45514336ab674a4118a0ff42296dc12a74e

src/gromacs/analysisdata/dataframe.cpp
src/gromacs/selection/selection.h
src/gromacs/utility/arrayref.h

index d6f638e9ca7febf647ec9a7e2c1feab7c94b0b54..e20cc4ea13b12ddece0453e4c9ad15945ecac5bb 100644 (file)
@@ -160,7 +160,7 @@ AnalysisDataFrameRef::AnalysisDataFrameRef(
 
 AnalysisDataFrameRef::AnalysisDataFrameRef(
         const AnalysisDataFrameRef &frame, int firstColumn, int columnCount)
-    : header_(frame.header()), values_(columnCount, &frame.values_[firstColumn])
+    : header_(frame.header()), values_(&frame.values_[firstColumn], columnCount)
 {
     GMX_ASSERT(firstColumn >= 0, "Invalid first column");
     GMX_ASSERT(columnCount >= 0, "Invalid column count");
index ca2af5783fc6c6c232b7927d5fec61cc26c79cbb..c87f5b40585e774a06e2346e049703dfbd383575 100644 (file)
@@ -294,8 +294,8 @@ class Selection
             {
                 return ConstArrayRef<int>();
             }
-            return ConstArrayRef<int>(data().rawPositions_.g->isize,
-                                      data().rawPositions_.g->index);
+            return ConstArrayRef<int>(data().rawPositions_.g->index,
+                                      data().rawPositions_.g->isize);
         }
         //! Number of positions in the selection.
         int posCount() const { return data().posCount(); }
@@ -304,7 +304,7 @@ class Selection
         //! Returns coordinates for this selection as a continuous array.
         ConstArrayRef<rvec> coordinates() const
         {
-            return ConstArrayRef<rvec>(posCount(), data().rawPositions_.x);
+            return ConstArrayRef<rvec>(data().rawPositions_.x, posCount());
         }
         //! Returns whether velocities are available for this selection.
         bool hasVelocities() const { return data().rawPositions_.v != NULL; }
@@ -316,7 +316,7 @@ class Selection
         ConstArrayRef<rvec> velocities() const
         {
             GMX_ASSERT(hasVelocities(), "Velocities accessed, but unavailable");
-            return ConstArrayRef<rvec>(posCount(), data().rawPositions_.v);
+            return ConstArrayRef<rvec>(data().rawPositions_.v, posCount());
         }
         //! Returns whether forces are available for this selection.
         bool hasForces() const { return sel_->rawPositions_.f != NULL; }
@@ -328,7 +328,7 @@ class Selection
         ConstArrayRef<rvec> forces() const
         {
             GMX_ASSERT(hasForces(), "Forces accessed, but unavailable");
-            return ConstArrayRef<rvec>(posCount(), data().rawPositions_.f);
+            return ConstArrayRef<rvec>(data().rawPositions_.f, posCount());
         }
         //! Returns masses for this selection as a continuous array.
         ConstArrayRef<real> masses() const
@@ -359,7 +359,7 @@ class Selection
          */
         ConstArrayRef<int> refIds() const
         {
-            return ConstArrayRef<int>(posCount(), data().rawPositions_.m.refid);
+            return ConstArrayRef<int>(data().rawPositions_.m.refid, posCount());
         }
         /*! \brief
          * Returns mapped IDs for this selection as a continuous array.
@@ -368,7 +368,7 @@ class Selection
          */
         ConstArrayRef<int> mappedIds() const
         {
-            return ConstArrayRef<int>(posCount(), data().rawPositions_.m.mapid);
+            return ConstArrayRef<int>(data().rawPositions_.m.mapid, posCount());
         }
         /*! \brief
          * Sets the ID for the \p i'th position for use with
@@ -567,8 +567,8 @@ class SelectionPosition
                 return ConstArrayRef<int>();
             }
             int first = sel_->rawPositions_.m.mapb.index[i_];
-            return ConstArrayRef<int>(atomCount(),
-                                      &sel_->rawPositions_.g->index[first]);
+            return ConstArrayRef<int>(&sel_->rawPositions_.g->index[first],
+                                      atomCount());
         }
         /*! \brief
          * Returns whether this position is selected in the current frame.
index 471839de68ff68fedf4a85bc9ef95b67289b3001..8456d31021eedb4de45e1c8608ef3b81d0cf5753 100644 (file)
@@ -132,13 +132,13 @@ class ConstArrayRef
         /*! \brief
          * Constructs a reference to an array.
          *
-         * \param[in] size   Number of elements in the array.
          * \param[in] begin  Pointer to the beginning of the array.
          *      May be NULL if \p size is zero.
+         * \param[in] size   Number of elements in the array.
          *
          * Passed pointer must remain valid for the lifetime of this object.
          */
-        ConstArrayRef(size_type size, const_pointer begin)
+        ConstArrayRef(const_pointer begin, size_type size)
             : begin_(begin), end_(begin + size)
         {
         }