Adaptagrams
cbuffer.h
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libvpsc - A solver for the problem of Variable Placement with
5  * Separation Constraints.
6  *
7  * Copyright (C) 2005-2008 Monash University
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  * See the file LICENSE.LGPL distributed with the library.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18  *
19  * Author(s): Tim Dwyer
20  *
21  */
22 #ifndef VPSC_CBUFFER_H
23 #define VPSC_CBUFFER_H
24 
25 #include <vector>
26 
27 namespace vpsc {
28  class Constraint;
29  class CBuffer {
30  public:
31  CBuffer(std::vector<Constraint*>& l,
32  const unsigned maxsize=5)
33  : master_list(l), maxsize(maxsize), size(0) {
34  buffer.resize(maxsize);
35  load();
36  }
37  void reset() { size=0; }
38  void load();
39  Constraint* mostViolated();
40  private:
41  std::vector<Constraint*>& master_list;
42  std::vector<Constraint*> buffer;
43  const unsigned maxsize;
44  unsigned size;
45  };
46 }
47 
48 #endif // VPSC_CBUFFER_H
49 
libvpsc: Variable Placement with Separation Constraints quadratic program solver library.
Definition: assertions.h:61