~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_bitmap.h

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include <mysys/my_bitmap.h>
30
30
 
31
 
template <uint default_width> class Bitmap
 
31
template <uint32_t default_width> class Bitmap
32
32
{
33
33
  MY_BITMAP map;
34
34
  uint32_t buffer[(default_width+31)/32];
35
35
public:
36
36
  Bitmap() { init(); }
37
37
  Bitmap(const Bitmap& from) { *this=from; }
38
 
  explicit Bitmap(uint prefix_to_set) { init(prefix_to_set); }
 
38
  explicit Bitmap(uint32_t prefix_to_set) { init(prefix_to_set); }
39
39
  void init() { bitmap_init(&map, buffer, default_width, 0); }
40
 
  void init(uint prefix_to_set) { init(); set_prefix(prefix_to_set); }
41
 
  uint length() const { return default_width; }
 
40
  void init(uint32_t prefix_to_set) { init(); set_prefix(prefix_to_set); }
 
41
  uint32_t length() const { return default_width; }
42
42
  Bitmap& operator=(const Bitmap& map2)
43
43
  {
44
44
    init();
45
45
    memcpy(buffer, map2.buffer, sizeof(buffer));
46
46
    return *this;
47
47
  }
48
 
  void set_bit(uint n) { bitmap_set_bit(&map, n); }
49
 
  void clear_bit(uint n) { bitmap_clear_bit(&map, n); }
50
 
  void set_prefix(uint n) { bitmap_set_prefix(&map, n); }
 
48
  void set_bit(uint32_t n) { bitmap_set_bit(&map, n); }
 
49
  void clear_bit(uint32_t n) { bitmap_clear_bit(&map, n); }
 
50
  void set_prefix(uint32_t n) { bitmap_set_prefix(&map, n); }
51
51
  void set_all() { bitmap_set_all(&map); }
52
52
  void clear_all() { bitmap_clear_all(&map); }
53
53
  void intersect(Bitmap& map2) { bitmap_intersect(&map, &map2.map); }
67
67
  }
68
68
  void subtract(Bitmap& map2) { bitmap_subtract(&map, &map2.map); }
69
69
  void merge(Bitmap& map2) { bitmap_union(&map, &map2.map); }
70
 
  bool is_set(uint n) const { return bitmap_is_set(&map, n); }
 
70
  bool is_set(uint32_t n) const { return bitmap_is_set(&map, n); }
71
71
  bool is_set() const { return !bitmap_is_clear_all(&map); }
72
 
  bool is_prefix(uint n) const { return bitmap_is_prefix(&map, n); }
 
72
  bool is_prefix(uint32_t n) const { return bitmap_is_prefix(&map, n); }
73
73
  bool is_clear_all() const { return bitmap_is_clear_all(&map); }
74
74
  bool is_set_all() const { return bitmap_is_set_all(&map); }
75
75
  bool is_subset(const Bitmap& map2) const { return bitmap_is_subset(&map, &map2.map); }
76
76
  bool is_overlapping(const Bitmap& map2) const { return bitmap_is_overlapping(&map, &map2.map); }
77
77
  bool operator==(const Bitmap& map2) const { return bitmap_cmp(&map, &map2.map); }
78
78
  bool operator!=(const Bitmap& map2) const { return !bitmap_cmp(&map, &map2.map); }
79
 
  Bitmap operator&=(uint n)
 
79
  Bitmap operator&=(uint32_t n)
80
80
  {
81
81
    if (bitmap_is_set(&map, n))
82
82
    {
92
92
    bitmap_intersect(&map, &map2.map);
93
93
    return *this;
94
94
  }
95
 
  Bitmap operator&(uint n)
 
95
  Bitmap operator&(uint32_t n)
96
96
  {
97
97
    Bitmap bm(*this);
98
98
    bm&= n;
104
104
    bm&= map2;
105
105
    return bm;
106
106
  }
107
 
  Bitmap operator|=(uint n)
 
107
  Bitmap operator|=(uint32_t n)
108
108
  {
109
109
    bitmap_set_bit(&map, n);
110
110
    return *this;
113
113
  {
114
114
    bitmap_union(&map, &map2.map);
115
115
  }
116
 
  Bitmap operator|(uint n)
 
116
  Bitmap operator|(uint32_t n)
117
117
  {
118
118
    Bitmap bm(*this);
119
119
    bm|= n;
162
162
  uint64_t map;
163
163
public:
164
164
  Bitmap<64>() { map= 0; }
165
 
  explicit Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); }
 
165
  explicit Bitmap<64>(uint32_t prefix_to_set) { set_prefix(prefix_to_set); }
166
166
  void init() { }
167
 
  void init(uint prefix_to_set) { set_prefix(prefix_to_set); }
168
 
  uint length() const { return 64; }
169
 
  void set_bit(uint n) { map|= ((uint64_t)1) << n; }
170
 
  void clear_bit(uint n) { map&= ~(((uint64_t)1) << n); }
171
 
  void set_prefix(uint n)
 
167
  void init(uint32_t prefix_to_set) { set_prefix(prefix_to_set); }
 
168
  uint32_t length() const { return 64; }
 
169
  void set_bit(uint32_t n) { map|= ((uint64_t)1) << n; }
 
170
  void clear_bit(uint32_t n) { map&= ~(((uint64_t)1) << n); }
 
171
  void set_prefix(uint32_t n)
172
172
  {
173
173
    if (n >= length())
174
174
      set_all();
182
182
  void intersect_extended(uint64_t map2) { map&= map2; }
183
183
  void subtract(Bitmap<64>& map2) { map&= ~map2.map; }
184
184
  void merge(Bitmap<64>& map2) { map|= map2.map; }
185
 
  bool is_set(uint n) const { return test(map & (((uint64_t)1) << n)); }
186
 
  bool is_prefix(uint n) const { return map == (((uint64_t)1) << n)-1; }
 
185
  bool is_set(uint32_t n) const { return test(map & (((uint64_t)1) << n)); }
 
186
  bool is_prefix(uint32_t n) const { return map == (((uint64_t)1) << n)-1; }
187
187
  bool is_clear_all() const { return map == (uint64_t)0; }
188
188
  bool is_set_all() const { return map == ~(uint64_t)0; }
189
189
  bool is_subset(const Bitmap<64>& map2) const { return !(map & ~map2.map); }
198
198
class Table_map_iterator
199
199
{
200
200
  uint64_t bmp;
201
 
  uint no;
 
201
  uint32_t no;
202
202
public:
203
203
  Table_map_iterator(uint64_t t) : bmp(t), no(0) {}
204
204
  int next_bit()
207
207
                                      2, 0, 1, 0, 
208
208
                                      3, 0, 1, 0,
209
209
                                      2, 0, 1, 0};
210
 
    uint bit;
 
210
    uint32_t bit;
211
211
    while ((bit= last_bit[bmp & 0xF]) == 32)
212
212
    {
213
213
      no += 4;