~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to sql/sql_bitmap.h

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
  }
153
153
};
154
154
 
 
155
/* An iterator to quickly walk over bits in unlonglong bitmap. */
 
156
class Table_map_iterator
 
157
{
 
158
  ulonglong bmp;
 
159
  uint no;
 
160
public:
 
161
  Table_map_iterator(ulonglong t) : bmp(t), no(0) {}
 
162
  int next_bit()
 
163
  {
 
164
    static const char last_bit[16]= {32, 0, 1, 0, 
 
165
                                      2, 0, 1, 0, 
 
166
                                      3, 0, 1, 0,
 
167
                                      2, 0, 1, 0};
 
168
    uint bit;
 
169
    while ((bit= last_bit[bmp & 0xF]) == 32)
 
170
    {
 
171
      no += 4;
 
172
      bmp= bmp >> 4;
 
173
      if (!bmp)
 
174
        return BITMAP_END;
 
175
    }
 
176
    bmp &= ~(1LL << bit);
 
177
    return no + bit;
 
178
  }
 
179
  enum { BITMAP_END= 64 };
 
180
};
 
181
 
 
182
 
155
183
template <> class Bitmap<64>
156
184
{
157
185
  ulonglong map;
158
186
public:
159
 
  Bitmap<64>() { map= 0; }
 
187
  Bitmap<64>() { init(); }
160
188
#if defined(__NETWARE__) || defined(__MWERKS__)
161
189
  /*
162
190
    Metwork compiler gives error on Bitmap<64>
167
195
#else
168
196
  explicit Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); }
169
197
#endif
170
 
  void init() { }
 
198
  void init() { clear_all(); }
171
199
  void init(uint prefix_to_set) { set_prefix(prefix_to_set); }
172
200
  uint length() const { return 64; }
173
201
  void set_bit(uint n) { map|= ((ulonglong)1) << n; }
195
223
  my_bool operator==(const Bitmap<64>& map2) const { return map == map2.map; }
196
224
  char *print(char *buf) const { longlong2str(map,buf,16); return buf; }
197
225
  ulonglong to_ulonglong() const { return map; }
198
 
};
199
 
 
200
 
 
201
 
/* An iterator to quickly walk over bits in unlonglong bitmap. */
202
 
class Table_map_iterator
203
 
{
204
 
  ulonglong bmp;
205
 
  uint no;
206
 
public:
207
 
  Table_map_iterator(ulonglong t) : bmp(t), no(0) {}
208
 
  int next_bit()
 
226
 
 
227
  class Iterator : public Table_map_iterator
209
228
  {
210
 
    static const char last_bit[16]= {32, 0, 1, 0, 
211
 
                                      2, 0, 1, 0, 
212
 
                                      3, 0, 1, 0,
213
 
                                      2, 0, 1, 0};
214
 
    uint bit;
215
 
    while ((bit= last_bit[bmp & 0xF]) == 32)
216
 
    {
217
 
      no += 4;
218
 
      bmp= bmp >> 4;
219
 
      if (!bmp)
220
 
        return BITMAP_END;
221
 
    }
222
 
    bmp &= ~(1LL << bit);
223
 
    return no + bit;
224
 
  }
225
 
  enum { BITMAP_END= 64 };
 
229
  public:
 
230
    Iterator(Bitmap<64> &bmp) : Table_map_iterator(bmp.map) {}
 
231
  };
226
232
};
227
233
 
228
234
 
 
235
 
229
236
#if 0
230
237
void print_bits(table_map bmp)
231
238
{