Index: lemon/lp_base.h
===================================================================
--- lemon/lp_base.h	(revision 1092)
+++ lemon/lp_base.h	(revision 1130)
@@ -32,4 +32,6 @@
 #include<lemon/bits/solver_bits.h>
 
+#include<lemon/bits/stl_iterators.h>
+
 ///\file
 ///\brief The interface of the LP solver interface.
@@ -46,6 +48,6 @@
   protected:
 
-    _solver_bits::VarIndex rows;
-    _solver_bits::VarIndex cols;
+    _solver_bits::VarIndex _rows;
+    _solver_bits::VarIndex _cols;
 
   public:
@@ -167,5 +169,5 @@
       ColIt(const LpBase &solver) : _solver(&solver)
       {
-        _solver->cols.firstItem(_id);
+        _solver->_cols.firstItem(_id);
       }
       /// Invalid constructor \& conversion
@@ -180,8 +182,23 @@
       ColIt &operator++()
       {
-        _solver->cols.nextItem(_id);
+        _solver->_cols.nextItem(_id);
         return *this;
       }
     };
+
+    /// \brief Gets the collection of the columns of the LP problem.
+    ///
+    /// This function can be used for iterating on
+    /// the columns of the LP problem. It returns a wrapped ColIt, which looks
+    /// like an STL container (by having begin() and end())
+    /// which you can use in range-based for loops, STL algorithms, etc.
+    /// For example you can write:
+    ///\code
+    /// for(auto c: lp.cols())
+    ///   doSomething(c);
+    LemonRangeWrapper1<ColIt, LpBase> cols() {
+      return LemonRangeWrapper1<ColIt, LpBase>(*this);
+    }
+
 
     /// \brief Returns the ID of the column.
@@ -262,5 +279,5 @@
       RowIt(const LpBase &solver) : _solver(&solver)
       {
-        _solver->rows.firstItem(_id);
+        _solver->_rows.firstItem(_id);
       }
       /// Invalid constructor \& conversion
@@ -275,8 +292,23 @@
       RowIt &operator++()
       {
-        _solver->rows.nextItem(_id);
+        _solver->_rows.nextItem(_id);
         return *this;
       }
     };
+    
+    /// \brief Gets the collection of the rows of the LP problem.
+    ///
+    /// This function can be used for iterating on
+    /// the rows of the LP problem. It returns a wrapped RowIt, which looks
+    /// like an STL container (by having begin() and end())
+    /// which you can use in range-based for loops, STL algorithms, etc.
+    /// For example you can write:
+    ///\code
+    /// for(auto c: lp.rows())
+    ///   doSomething(c);
+    LemonRangeWrapper1<RowIt, LpBase> rows() {
+      return LemonRangeWrapper1<RowIt, LpBase>(*this);
+    }
+    
 
     /// \brief Returns the ID of the row.
@@ -935,9 +967,9 @@
     //Abstract virtual functions
 
-    virtual int _addColId(int col) { return cols.addIndex(col); }
-    virtual int _addRowId(int row) { return rows.addIndex(row); }
-
-    virtual void _eraseColId(int col) { cols.eraseIndex(col); }
-    virtual void _eraseRowId(int row) { rows.eraseIndex(row); }
+    virtual int _addColId(int col) { return _cols.addIndex(col); }
+    virtual int _addRowId(int row) { return _rows.addIndex(row); }
+
+    virtual void _eraseColId(int col) { _cols.eraseIndex(col); }
+    virtual void _eraseRowId(int row) { _rows.eraseIndex(row); }
 
     virtual int _addCol() = 0;
@@ -1004,5 +1036,5 @@
     Value obj_const_comp;
 
-    LpBase() : rows(), cols(), obj_const_comp(0) {}
+    LpBase() : _rows(), _cols(), obj_const_comp(0) {}
 
   public:
@@ -1116,6 +1148,6 @@
     void col(Col c, const DualExpr &e) {
       e.simplify();
-      _setColCoeffs(cols(id(c)), ExprIterator(e.comps.begin(), rows),
-                    ExprIterator(e.comps.end(), rows));
+      _setColCoeffs(_cols(id(c)), ExprIterator(e.comps.begin(), _rows),
+                    ExprIterator(e.comps.end(), _rows));
     }
 
@@ -1126,5 +1158,5 @@
     DualExpr col(Col c) const {
       DualExpr e;
-      _getColCoeffs(cols(id(c)), InsertIterator(e.comps, rows));
+      _getColCoeffs(_cols(id(c)), InsertIterator(e.comps, _rows));
       return e;
     }
@@ -1213,8 +1245,8 @@
     void row(Row r, Value l, const Expr &e, Value u) {
       e.simplify();
-      _setRowCoeffs(rows(id(r)), ExprIterator(e.comps.begin(), cols),
-                    ExprIterator(e.comps.end(), cols));
-      _setRowLowerBound(rows(id(r)),l - *e);
-      _setRowUpperBound(rows(id(r)),u - *e);
+      _setRowCoeffs(_rows(id(r)), ExprIterator(e.comps.begin(), _cols),
+                    ExprIterator(e.comps.end(), _cols));
+      _setRowLowerBound(_rows(id(r)),l - *e);
+      _setRowUpperBound(_rows(id(r)),u - *e);
     }
 
@@ -1235,5 +1267,5 @@
     Expr row(Row r) const {
       Expr e;
-      _getRowCoeffs(rows(id(r)), InsertIterator(e.comps, cols));
+      _getRowCoeffs(_rows(id(r)), InsertIterator(e.comps, _cols));
       return e;
     }
@@ -1248,6 +1280,6 @@
       Row r;
       e.simplify();
-      r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols),
-                                ExprIterator(e.comps.end(), cols), u - *e));
+      r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), _cols),
+                                ExprIterator(e.comps.end(), _cols), u - *e));
       return r;
     }
@@ -1261,6 +1293,6 @@
       c.expr().simplify();
       r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound()-*c.expr():-INF,
-                                ExprIterator(c.expr().comps.begin(), cols),
-                                ExprIterator(c.expr().comps.end(), cols),
+                                ExprIterator(c.expr().comps.begin(), _cols),
+                                ExprIterator(c.expr().comps.end(), _cols),
                                 c.upperBounded()?c.upperBound()-*c.expr():INF));
       return r;
@@ -1270,6 +1302,6 @@
     ///\param c is the column to be deleted
     void erase(Col c) {
-      _eraseCol(cols(id(c)));
-      _eraseColId(cols(id(c)));
+      _eraseCol(_cols(id(c)));
+      _eraseColId(_cols(id(c)));
     }
     ///Erase a row (i.e a constraint) from the LP
@@ -1277,6 +1309,6 @@
     ///\param r is the row to be deleted
     void erase(Row r) {
-      _eraseRow(rows(id(r)));
-      _eraseRowId(rows(id(r)));
+      _eraseRow(_rows(id(r)));
+      _eraseRowId(_rows(id(r)));
     }
 
@@ -1287,5 +1319,5 @@
     std::string colName(Col c) const {
       std::string name;
-      _getColName(cols(id(c)), name);
+      _getColName(_cols(id(c)), name);
       return name;
     }
@@ -1296,5 +1328,5 @@
     ///\param name The name to be given
     void colName(Col c, const std::string& name) {
-      _setColName(cols(id(c)), name);
+      _setColName(_cols(id(c)), name);
     }
 
@@ -1305,5 +1337,5 @@
     Col colByName(const std::string& name) const {
       int k = _colByName(name);
-      return k != -1 ? Col(cols[k]) : Col(INVALID);
+      return k != -1 ? Col(_cols[k]) : Col(INVALID);
     }
 
@@ -1314,5 +1346,5 @@
     std::string rowName(Row r) const {
       std::string name;
-      _getRowName(rows(id(r)), name);
+      _getRowName(_rows(id(r)), name);
       return name;
     }
@@ -1323,5 +1355,5 @@
     ///\param name The name to be given
     void rowName(Row r, const std::string& name) {
-      _setRowName(rows(id(r)), name);
+      _setRowName(_rows(id(r)), name);
     }
 
@@ -1332,5 +1364,5 @@
     Row rowByName(const std::string& name) const {
       int k = _rowByName(name);
-      return k != -1 ? Row(rows[k]) : Row(INVALID);
+      return k != -1 ? Row(_rows[k]) : Row(INVALID);
     }
 
@@ -1341,5 +1373,5 @@
     ///\param val is the new value of the coefficient
     void coeff(Row r, Col c, Value val) {
-      _setCoeff(rows(id(r)),cols(id(c)), val);
+      _setCoeff(_rows(id(r)),_cols(id(c)), val);
     }
 
@@ -1350,5 +1382,5 @@
     ///\return the corresponding coefficient
     Value coeff(Row r, Col c) const {
-      return _getCoeff(rows(id(r)),cols(id(c)));
+      return _getCoeff(_rows(id(r)),_cols(id(c)));
     }
 
@@ -1359,5 +1391,5 @@
     /// Value or -\ref INF.
     void colLowerBound(Col c, Value value) {
-      _setColLowerBound(cols(id(c)),value);
+      _setColLowerBound(_cols(id(c)),value);
     }
 
@@ -1368,5 +1400,5 @@
     ///\return The lower bound for column \c c
     Value colLowerBound(Col c) const {
-      return _getColLowerBound(cols(id(c)));
+      return _getColLowerBound(_cols(id(c)));
     }
 
@@ -1414,5 +1446,5 @@
     /// Value or \ref INF.
     void colUpperBound(Col c, Value value) {
-      _setColUpperBound(cols(id(c)),value);
+      _setColUpperBound(_cols(id(c)),value);
     };
 
@@ -1423,5 +1455,5 @@
     /// \return The upper bound for column \c c
     Value colUpperBound(Col c) const {
-      return _getColUpperBound(cols(id(c)));
+      return _getColUpperBound(_cols(id(c)));
     }
 
@@ -1470,6 +1502,6 @@
     /// Value, -\ref INF or \ref INF.
     void colBounds(Col c, Value lower, Value upper) {
-      _setColLowerBound(cols(id(c)),lower);
-      _setColUpperBound(cols(id(c)),upper);
+      _setColLowerBound(_cols(id(c)),lower);
+      _setColUpperBound(_cols(id(c)),upper);
     }
 
@@ -1516,5 +1548,5 @@
     /// Value or -\ref INF.
     void rowLowerBound(Row r, Value value) {
-      _setRowLowerBound(rows(id(r)),value);
+      _setRowLowerBound(_rows(id(r)),value);
     }
 
@@ -1525,5 +1557,5 @@
     ///\return The lower bound for row \c r
     Value rowLowerBound(Row r) const {
-      return _getRowLowerBound(rows(id(r)));
+      return _getRowLowerBound(_rows(id(r)));
     }
 
@@ -1534,5 +1566,5 @@
     /// Value or -\ref INF.
     void rowUpperBound(Row r, Value value) {
-      _setRowUpperBound(rows(id(r)),value);
+      _setRowUpperBound(_rows(id(r)),value);
     }
 
@@ -1543,12 +1575,12 @@
     ///\return The upper bound for row \c r
     Value rowUpperBound(Row r) const {
-      return _getRowUpperBound(rows(id(r)));
+      return _getRowUpperBound(_rows(id(r)));
     }
 
     ///Set an element of the objective function
-    void objCoeff(Col c, Value v) {_setObjCoeff(cols(id(c)),v); };
+    void objCoeff(Col c, Value v) {_setObjCoeff(_cols(id(c)),v); };
 
     ///Get an element of the objective function
-    Value objCoeff(Col c) const { return _getObjCoeff(cols(id(c))); };
+    Value objCoeff(Col c) const { return _getObjCoeff(_cols(id(c))); };
 
     ///Set the objective function
@@ -1557,6 +1589,6 @@
     ///
     void obj(const Expr& e) {
-      _setObjCoeffs(ExprIterator(e.comps.begin(), cols),
-                    ExprIterator(e.comps.end(), cols));
+      _setObjCoeffs(ExprIterator(e.comps.begin(), _cols),
+                    ExprIterator(e.comps.end(), _cols));
       obj_const_comp = *e;
     }
@@ -1568,5 +1600,5 @@
     Expr obj() const {
       Expr e;
-      _getObjCoeffs(InsertIterator(e.comps, cols));
+      _getObjCoeffs(InsertIterator(e.comps, _cols));
       *e = obj_const_comp;
       return e;
@@ -1587,5 +1619,5 @@
 
     ///Clear the problem
-    void clear() { _clear(); rows.clear(); cols.clear(); }
+    void clear() { _clear(); _rows.clear(); _cols.clear(); }
 
     /// Set the message level of the solver
@@ -1930,5 +1962,5 @@
     /// Return the primal value of the column.
     /// \pre The problem is solved.
-    Value primal(Col c) const { return _getPrimal(cols(id(c))); }
+    Value primal(Col c) const { return _getPrimal(_cols(id(c))); }
 
     /// Return the primal value of the expression
@@ -1957,5 +1989,5 @@
     /// \note Some solvers does not provide primal ray calculation
     /// functions.
-    Value primalRay(Col c) const { return _getPrimalRay(cols(id(c))); }
+    Value primalRay(Col c) const { return _getPrimalRay(_cols(id(c))); }
 
     /// Return the dual value of the row
@@ -1963,5 +1995,5 @@
     /// Return the dual value of the row.
     /// \pre The problem is solved.
-    Value dual(Row r) const { return _getDual(rows(id(r))); }
+    Value dual(Row r) const { return _getDual(_rows(id(r))); }
 
     /// Return the dual value of the dual expression
@@ -1991,15 +2023,15 @@
     /// \note Some solvers does not provide dual ray calculation
     /// functions.
-    Value dualRay(Row r) const { return _getDualRay(rows(id(r))); }
+    Value dualRay(Row r) const { return _getDualRay(_rows(id(r))); }
 
     /// Return the basis status of the column
 
     /// \see VarStatus
-    VarStatus colStatus(Col c) const { return _getColStatus(cols(id(c))); }
+    VarStatus colStatus(Col c) const { return _getColStatus(_cols(id(c))); }
 
     /// Return the basis status of the row
 
     /// \see VarStatus
-    VarStatus rowStatus(Row r) const { return _getRowStatus(rows(id(r))); }
+    VarStatus rowStatus(Row r) const { return _getRowStatus(_rows(id(r))); }
 
     ///The value of the objective function
@@ -2081,5 +2113,5 @@
     ///
     void colType(Col c, ColTypes col_type) {
-      _setColType(cols(id(c)),col_type);
+      _setColType(_cols(id(c)),col_type);
     }
 
@@ -2089,5 +2121,5 @@
     ///
     ColTypes colType(Col c) const {
-      return _getColType(cols(id(c)));
+      return _getColType(_cols(id(c)));
     }
     ///@}
@@ -2106,5 +2138,5 @@
     ///  Return the value of the row in the solution.
     /// \pre The problem is solved.
-    Value sol(Col c) const { return _getSol(cols(id(c))); }
+    Value sol(Col c) const { return _getSol(_cols(id(c))); }
 
     /// Return the value of the expression in the solution
