# HG changeset patch
# User Balazs Dezso <deba@inf.elte.hu>
# Date 1336237264 -7200
# Node ID 55c6560a7c0fd2334c394d2ccd9644168cd1c7df
# Parent  cfbabca1b4e9b8d4ce408f853db728509d020110
Fix clear() in VarIndex

diff -r cfbabca1b4e9 -r 55c6560a7c0f lemon/bits/solver_bits.h
--- a/lemon/bits/solver_bits.h	Fri Feb 03 05:55:39 2012 +0100
+++ b/lemon/bits/solver_bits.h	Sat May 05 19:01:04 2012 +0200
@@ -44,6 +44,7 @@
 
       void clear() {
         first_item = -1;
+        last_item = -1;
         first_free_item = -1;
         items.clear();
         cross.clear();
diff -r cfbabca1b4e9 -r 55c6560a7c0f lemon/lp_skeleton.cc
--- a/lemon/lp_skeleton.cc	Fri Feb 03 05:55:39 2012 +0100
+++ b/lemon/lp_skeleton.cc	Sat May 05 19:01:04 2012 +0200
@@ -87,6 +87,7 @@
 
   void SkeletonSolverBase::_clear() {
     row_num = col_num = 0;
+    rows.clear(); cols.clear();
   }
 
   void SkeletonSolverBase::_messageLevel(MessageLevel) {}
diff -r cfbabca1b4e9 -r 55c6560a7c0f test/lp_test.cc
--- a/test/lp_test.cc	Fri Feb 03 05:55:39 2012 +0100
+++ b/test/lp_test.cc	Sat May 05 19:01:04 2012 +0200
@@ -41,6 +41,18 @@
 
 using namespace lemon;
 
+int countCols(LpSolver& lp) {
+  int count = 0;
+  for (LpSolver::ColIt c(lp); c != INVALID; ++c) ++count;
+  return count;
+}
+
+int countRows(LpSolver& lp) {
+  int count = 0;
+  for (LpSolver::RowIt r(lp); r != INVALID; ++r) ++count;
+  return count;
+}
+
 void lpTest(LpSolver& lp)
 {
 
@@ -244,6 +256,23 @@
        );
   }
 
+  { //Tests for #441
+    check(countCols(lp) == 30, "Wrong number of columns");
+    check(countRows(lp) == 6, "Wrong number of rows");
+
+    lp.clear();
+
+    check(countCols(lp) == 0, "Wrong number of columns");
+    check(countRows(lp) == 0, "Wrong number of rows");
+
+    LP::Col p1;
+    p1=lp.addCol();
+    std::cerr << countCols(lp) << std::endl;
+    check(countCols(lp) == 1, "Wrong number of columns");
+
+    lp.addRow(p1==1);
+    check(countRows(lp) == 1, "Wrong number of rows");
+  }
 }
 
 void solveAndCheck(LpSolver& lp, LpSolver::ProblemType stat,
