COIN-OR::LEMON - Graph Library

Changeset 2303:005b3f927287 in lemon-0.x


Ignore:
Timestamp:
11/14/06 10:49:26 (17 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3076
Message:

ColIt? added. (Untested, but at least it compiles.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_base.h

    r2268 r2303  
    4040  {
    4141  protected:
     42    int _first_index;
     43    int first_free;
     44  public:
    4245    std::vector<int> index;
    4346    std::vector<int> cross;
    44     int first_free;
    45   public:
    46     _FixId() : first_free(-1) {};
     47    _FixId() : _first_index(-1), first_free(-1) {};
    4748    ///Convert a floating id to a fix one
    4849
     
    6263    int insert(int n)
    6364    {
     65      if(cross.empty()) _first_index=n;
    6466      if(n>=int(cross.size())) {
    6567        cross.resize(n+1);
     
    102104    std::size_t maxFixId() { return cross.size()-1; }
    103105 
     106    ///Returns the first (smallest) inserted index
     107
     108    ///Returns the first (smallest) inserted index
     109    ///or -1 if no index has been inserted before.
     110    int firstIndex() {return _first_index;}
    104111  };
    105112   
     
    109116  ///\ingroup gen_opt_group
    110117  class LpSolverBase {
     118
     119  protected:
     120    _FixId rows;
     121    _FixId cols;
    111122
    112123  public:
     
    164175
    165176    static inline bool isNaN(const Value& v) { return v!=v; }
     177   
     178    friend class Col;
     179    friend class ColIt;
     180    friend class Row;
    166181   
    167182    ///Refer to a column of the LP.
     
    190205    };
    191206
     207    class ColIt : public Col {
     208      LpSolverBase *_lp;
     209      ColIt() {}
     210      ColIt(LpSolverBase &lp) : _lp(&lp)
     211      {
     212        id = _lp->cols.cross.empty()?-1:
     213          _lp->cols.fixId(_lp->cols.firstIndex());
     214      }
     215      ColIt(const Invalid&) : Col(INVALID) {}
     216      ColIt &operator++()
     217      {
     218        int fid = _lp->cols.floatingId(id)+1;
     219        id = unsigned(fid)<_lp->cols.cross.size() ? _lp->cols.fixId(fid) : -1;
     220        return *this;
     221      }
     222    };
     223     
    192224    ///Refer to a row of the LP.
    193225
     
    565597
    566598  protected:
    567     _FixId rows;
    568     _FixId cols;
    569599
    570600    //Abstract virtual functions
     
    580610
    581611    virtual int _addCol() = 0;
    582     virtual int _addRow() = 0;
     612    virtual int _addRow() = 0; 
    583613    virtual void _eraseCol(int col) = 0;
    584614    virtual void _eraseRow(int row) = 0;
Note: See TracChangeset for help on using the changeset viewer.