GraphChi  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros
bitset_scheduler.hpp
Go to the documentation of this file.
1 
29 #ifndef DEF_GRAPHCHI_BITSETSCHEDULER
30 #define DEF_GRAPHCHI_BITSETSCHEDULER
31 
32 #include "graphchi_types.hpp"
33 #include "api/ischeduler.hpp"
34 #include "util/dense_bitset.hpp"
35 
36 namespace graphchi {
37 
38  class bitset_scheduler : public ischeduler {
39  private:
40  dense_bitset bitset;
41  public:
42  bool has_new_tasks;
43 
44  bitset_scheduler(int nvertices) : bitset(nvertices) {
45  }
46 
47  virtual ~bitset_scheduler() {}
48 
49  inline void add_task(vid_t vertex) {
50  bitset.set_bit(vertex);
51  has_new_tasks = true;
52  }
53 
54  void resize(vid_t maxsize) {
55  bitset.resize(maxsize);
56  }
57 
58  inline bool is_scheduled(vid_t vertex) {
59  return bitset.get(vertex);
60  }
61 
62  inline void remove_task(vid_t vertex) {
63  bitset.clear_bit(vertex);
64  }
65 
66  void remove_tasks(vid_t fromvertex, vid_t tovertex) {
67  bitset.clear_bits(fromvertex, tovertex);
68  }
69 
70  void add_task_to_all() {
71  has_new_tasks = true;
72  bitset.setall();
73  }
74  };
75 
76 }
77 
78 
79 #endif
80