ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
Reap Class Reference

#include <reap.hpp>

Public Member Functions

 Reap ()
 
void init ()
 
void release ()
 
bool empty ()
 
size_t size ()
 
void push (unsigned)
 
void clear ()
 
unsigned pop ()
 

Detailed Description

Definition at line 11 of file reap.hpp.

Constructor & Destructor Documentation

◆ Reap()

Reap::Reap ( )

Definition at line 35 of file cadical_reap.cpp.

35 {
36 num_elements = 0;
37 last_deleted = 0;
38 min_bucket = 32;
39 max_bucket = 0;
40}

Member Function Documentation

◆ clear()

void Reap::clear ( )

Definition at line 132 of file cadical_reap.cpp.

132 {
133 CADICAL_assert (max_bucket <= 32);
134 for (unsigned i = 0; i < 33; i++)
135 buckets[i].clear ();
136 num_elements = 0;
137 last_deleted = 0;
138 min_bucket = 32;
139 max_bucket = 0;
140}
#define CADICAL_assert(ignore)
Definition global.h:14
void clear()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

bool Reap::empty ( )
inline

Definition at line 16 of file reap.hpp.

16{ return !num_elements; }
Here is the caller graph for this function:

◆ init()

ABC_NAMESPACE_IMPL_START void Reap::init ( )

Definition at line 19 of file cadical_reap.cpp.

19 {
20 for (auto &bucket : buckets)
21 bucket = {0};
22 CADICAL_assert (!num_elements);
23 CADICAL_assert (!last_deleted);
24 min_bucket = 32;
25 CADICAL_assert (!max_bucket);
26}

◆ pop()

unsigned Reap::pop ( )

Definition at line 59 of file cadical_reap.cpp.

59 {
60 CADICAL_assert (num_elements > 0);
61 unsigned i = min_bucket;
62 for (;;) {
63 CADICAL_assert (i < 33);
64 CADICAL_assert (i <= max_bucket);
65 std::vector<unsigned> &s = buckets[i];
66 if (s.empty ()) {
67 min_bucket = ++i;
68 continue;
69 }
70 unsigned res;
71 if (i) {
72 res = UINT_MAX;
73 const auto begin = std::begin (s);
74 const auto end = std::end (s);
75 auto q = std::begin (s);
76 CADICAL_assert (begin < end);
77 for (auto p = begin; p != end; ++p) {
78 const unsigned tmp = *p;
79 if (tmp >= res)
80 continue;
81 res = tmp;
82 q = p;
83 }
84
85 for (auto p = begin; p != end; ++p) {
86 if (p == q)
87 continue;
88 const unsigned other = *p;
89 const unsigned diff = other ^ res;
90 CADICAL_assert (sizeof (unsigned) == 4);
91 const unsigned j = 32 - leading_zeroes_of_unsigned (diff);
92 CADICAL_assert (j < i);
93 buckets[j].push_back (other);
94 if (min_bucket > j)
95 min_bucket = j;
96 }
97
98 s.clear ();
99
100 if (i && max_bucket == i) {
101#ifndef CADICAL_NDEBUG
102 for (unsigned j = i + 1; j < 33; j++)
103 CADICAL_assert (buckets[j].empty ());
104#endif
105 if (s.empty ())
106 max_bucket = i - 1;
107 }
108 } else {
109 res = last_deleted;
110 CADICAL_assert (!buckets[0].empty ());
111 CADICAL_assert (buckets[0].at (0) == res);
112 buckets[0].pop_back ();
113 }
114
115 if (min_bucket == i) {
116#ifndef CADICAL_NDEBUG
117 for (unsigned j = 0; j < i; j++)
118 CADICAL_assert (buckets[j].empty ());
119#endif
120 if (s.empty ())
121 min_bucket = std::min ((int) (i + 1), 32);
122 }
123
124 --num_elements;
125 CADICAL_assert (last_deleted <= res);
126 last_deleted = res;
127
128 return res;
129 }
130}
bool empty()
Definition reap.hpp:16
Cube * p
Definition exorList.c:222
Here is the call graph for this function:

◆ push()

void Reap::push ( unsigned e)

Definition at line 46 of file cadical_reap.cpp.

46 {
47 CADICAL_assert (last_deleted <= e);
48 const unsigned diff = e ^ last_deleted;
49 const unsigned bucket = 32 - leading_zeroes_of_unsigned (diff);
50 buckets[bucket].push_back (e);
51 if (min_bucket > bucket)
52 min_bucket = bucket;
53 if (max_bucket < bucket)
54 max_bucket = bucket;
55 CADICAL_assert (num_elements != UINT_MAX);
56 num_elements++;
57}

◆ release()

void Reap::release ( )

Definition at line 28 of file cadical_reap.cpp.

28 {
29 num_elements = 0;
30 last_deleted = 0;
31 min_bucket = 32;
32 max_bucket = 0;
33}

◆ size()

size_t Reap::size ( )
inline

Definition at line 18 of file reap.hpp.

18{ return num_elements; }

The documentation for this class was generated from the following files: