Bitmask.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:17k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef NDB_BITMASK_H
  14. #define NDB_BITMASK_H
  15. #include <ndb_global.h>
  16. /**
  17.  * Bitmask implementation.  Size is given explicitly
  18.  * (as first argument).  All methods are static.
  19.  */
  20. class BitmaskImpl {
  21. public:
  22.   STATIC_CONST( NotFound = (unsigned)-1 );
  23.   /**
  24.    * get - Check if bit n is set.
  25.    */
  26.   static bool get(unsigned size, const Uint32 data[], unsigned n);
  27.   /**
  28.    * set - Set bit n to given value (true/false).
  29.    */
  30.   static void set(unsigned size, Uint32 data[], unsigned n, bool value);
  31.   /**
  32.    * set - Set bit n.
  33.    */
  34.   static void set(unsigned size, Uint32 data[], unsigned n);
  35.   /**
  36.    * set - Set all bits.
  37.    */
  38.   static void set(unsigned size, Uint32 data[]);
  39.   /**
  40.    * assign - Set all bits in <em>dst</em> to corresponding in <em>src/<em>
  41.    */
  42.   static void assign(unsigned size, Uint32 dst[], const Uint32 src[]);
  43.   /**
  44.    * clear - Clear bit n.
  45.    */
  46.   static void clear(unsigned size, Uint32 data[], unsigned n);
  47.   /**
  48.    * clear - Clear all bits.
  49.    */
  50.   static void clear(unsigned size, Uint32 data[]);
  51.   /**
  52.    * isclear -  Check if all bits are clear.  This is faster
  53.    * than checking count() == 0.
  54.    */
  55.   static bool isclear(unsigned size, const Uint32 data[]);
  56.   /**
  57.    * count - Count number of set bits.
  58.    */
  59.   static unsigned count(unsigned size, const Uint32 data[]);
  60.   /**
  61.    * find - Find first set bit, starting at given position.
  62.    * Returns NotFound when not found.
  63.    */
  64.   static unsigned find(unsigned size, const Uint32 data[], unsigned n);
  65.   /**
  66.    * equal - Bitwise equal.
  67.    */
  68.   static bool equal(unsigned size, const Uint32 data[], const Uint32 data2[]);
  69.   /**
  70.    * bitOR - Bitwise (x | y) into first operand.
  71.    */
  72.   static void bitOR(unsigned size, Uint32 data[], const Uint32 data2[]);
  73.   /**
  74.    * bitAND - Bitwise (x & y) into first operand.
  75.    */
  76.   static void bitAND(unsigned size, Uint32 data[], const Uint32 data2[]);
  77.   /**
  78.    * bitANDC - Bitwise (x & ~y) into first operand.
  79.    */
  80.   static void bitANDC(unsigned size, Uint32 data[], const Uint32 data2[]);
  81.   /**
  82.    * bitXOR - Bitwise (x ^ y) into first operand.
  83.    */
  84.   static void bitXOR(unsigned size, Uint32 data[], const Uint32 data2[]);
  85.   /**
  86.    * bitXORC - Bitwise (x ^ ~y) into first operand.
  87.    */
  88.   static void bitXORC(unsigned size, Uint32 data[], const Uint32 data2[]);
  89.   /**
  90.    * contains - Check if all bits set in data2 are set in data
  91.    */
  92.   static bool contains(unsigned size, Uint32 data[], const Uint32 data2[]);
  93.   /**
  94.    * overlaps - Check if any bit set in data is set in data2
  95.    */
  96.   static bool overlaps(unsigned size, Uint32 data[], const Uint32 data2[]);
  97.   /**
  98.    * getField - Get bitfield at given position and length (max 32 bits)
  99.    */
  100.   static Uint32 getField(unsigned size, const Uint32 data[],
  101.       unsigned pos, unsigned len);
  102.   /**
  103.    * setField - Set bitfield at given position and length (max 32 bits)
  104.    */
  105.   static void setField(unsigned size, Uint32 data[],
  106.       unsigned pos, unsigned len, Uint32 val);
  107.   /**
  108.    * getText - Return as hex-digits (only for debug routines).
  109.    */
  110.   static char* getText(unsigned size, const Uint32 data[], char* buf);
  111. };
  112. inline bool
  113. BitmaskImpl::get(unsigned size, const Uint32 data[], unsigned n)
  114. {
  115.   assert(n < (size << 5));
  116.   return (data[n >> 5] & (1 << (n & 31))) != 0;
  117. }
  118. inline void
  119. BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n, bool value)
  120. {
  121.   value ? set(size, data, n) : clear(size, data, n);
  122. }
  123. inline void
  124. BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n)
  125. {
  126.   assert(n < (size << 5));
  127.   data[n >> 5] |= (1 << (n & 31));
  128. }
  129. inline void
  130. BitmaskImpl::set(unsigned size, Uint32 data[])
  131. {
  132.   for (unsigned i = 0; i < size; i++) {
  133.     data[i] = ~0;
  134.   }
  135. }
  136. inline void 
  137. BitmaskImpl::assign(unsigned size, Uint32 dst[], const Uint32 src[])
  138. {
  139.   for (unsigned i = 0; i < size; i++) {
  140.     dst[i] = src[i];
  141.   }
  142. }
  143. inline void
  144. BitmaskImpl::clear(unsigned size, Uint32 data[], unsigned n)
  145. {
  146.   assert(n < (size << 5));
  147.   data[n >> 5] &= ~(1 << (n & 31));
  148. }
  149. inline void
  150. BitmaskImpl::clear(unsigned size, Uint32 data[])
  151. {
  152.   for (unsigned i = 0; i < size; i++) {
  153.     data[i] = 0;
  154.   }
  155. }
  156. inline bool
  157. BitmaskImpl::isclear(unsigned size, const Uint32 data[])
  158. {
  159.   for (unsigned i = 0; i < size; i++) {
  160.     if (data[i] != 0)
  161.       return false;
  162.   }
  163.   return true;
  164. }
  165. inline unsigned
  166. BitmaskImpl::count(unsigned size, const Uint32 data[])
  167. {
  168.   unsigned cnt = 0;
  169.   for (unsigned i = 0; i < size; i++) {
  170.     Uint32 x = data[i];
  171.     while (x) {
  172.       x &= (x - 1);
  173.       cnt++;
  174.     }
  175.   }
  176.   return cnt;
  177. }
  178. inline unsigned
  179. BitmaskImpl::find(unsigned size, const Uint32 data[], unsigned n)
  180. {
  181.   while (n < (size << 5)) {             // XXX make this smarter
  182.     if (get(size, data, n)) {
  183.       return n;
  184.     }
  185.     n++;
  186.   }
  187.   return NotFound;
  188. }
  189. inline bool
  190. BitmaskImpl::equal(unsigned size, const Uint32 data[], const Uint32 data2[])
  191. {
  192.   for (unsigned i = 0; i < size; i++) {
  193.     if (data[i] != data2[i])
  194.       return false;
  195.   }
  196.   return true;
  197. }
  198. inline void
  199. BitmaskImpl::bitOR(unsigned size, Uint32 data[], const Uint32 data2[])
  200. {
  201.   for (unsigned i = 0; i < size; i++) {
  202.     data[i] |= data2[i];
  203.   }
  204. }
  205. inline void
  206. BitmaskImpl::bitAND(unsigned size, Uint32 data[], const Uint32 data2[])
  207. {
  208.   for (unsigned i = 0; i < size; i++) {
  209.     data[i] &= data2[i];
  210.   }
  211. }
  212. inline void
  213. BitmaskImpl::bitANDC(unsigned size, Uint32 data[], const Uint32 data2[])
  214. {
  215.   for (unsigned i = 0; i < size; i++) {
  216.     data[i] &= ~data2[i];
  217.   }
  218. }
  219. inline void
  220. BitmaskImpl::bitXOR(unsigned size, Uint32 data[], const Uint32 data2[])
  221. {
  222.   for (unsigned i = 0; i < size; i++) {
  223.     data[i] ^= data2[i];
  224.   }
  225. }
  226. inline void
  227. BitmaskImpl::bitXORC(unsigned size, Uint32 data[], const Uint32 data2[])
  228. {
  229.   for (unsigned i = 0; i < size; i++) {
  230.     data[i] ^= ~data2[i];
  231.   }
  232. }
  233. inline bool
  234. BitmaskImpl::contains(unsigned size, Uint32 data[], const Uint32 data2[])
  235. {
  236.   for (unsigned int i = 0; i < size; i++)
  237.     if ((data[i] & data2[i]) != data2[i])
  238.       return false;
  239.   return true;
  240. }
  241. inline bool
  242. BitmaskImpl::overlaps(unsigned size, Uint32 data[], const Uint32 data2[])
  243. {
  244.   for (unsigned int i = 0; i < size; i++)
  245.     if ((data[i] & data2[i]) != 0)
  246.       return true;
  247.   return false;
  248. }
  249. inline Uint32
  250. BitmaskImpl::getField(unsigned size, const Uint32 data[],
  251.     unsigned pos, unsigned len)
  252. {
  253.   Uint32 val = 0;
  254.   for (unsigned i = 0; i < len; i++)
  255.     val |= get(size, data, pos + i) << i;
  256.   return val;
  257. }
  258. inline void
  259. BitmaskImpl::setField(unsigned size, Uint32 data[],
  260.     unsigned pos, unsigned len, Uint32 val)
  261. {
  262.   for (unsigned i = 0; i < len; i++)
  263.     set(size, data, pos + i, val & (1 << i));
  264. }
  265. inline char *
  266. BitmaskImpl::getText(unsigned size, const Uint32 data[], char* buf)
  267. {
  268.   char * org = buf;
  269.   const char* const hex = "0123456789abcdef";
  270.   for (int i = (size-1); i >= 0; i--) {
  271.     Uint32 x = data[i];
  272.     for (unsigned j = 0; j < 8; j++) {
  273.       buf[7-j] = hex[x & 0xf];
  274.       x >>= 4;
  275.     }
  276.     buf += 8;
  277.   }
  278.   *buf = 0;
  279.   return org;
  280. }
  281. /**
  282.  * Bitmasks.  The size is number of 32-bit words (Uint32).
  283.  * Unused bits in the last word must be zero.
  284.  *
  285.  * XXX replace size by length in bits
  286.  */
  287. template <unsigned size>
  288. struct BitmaskPOD {
  289. public:
  290.   /**
  291.    * POD data representation
  292.    */
  293.   struct Data {
  294.     Uint32 data[size];
  295. #if 0
  296.     Data & operator=(const BitmaskPOD<size> & src) {
  297.       src.copyto(size, data);
  298.       return *this;
  299.     }
  300. #endif
  301.   };
  302. private:
  303.   
  304.   Data rep;
  305. public:
  306.   STATIC_CONST( Size = size );
  307.   STATIC_CONST( NotFound = BitmaskImpl::NotFound );
  308.   STATIC_CONST( TextLength = size * 8 );
  309.   /**
  310.    * assign - Set all bits in <em>dst</em> to corresponding in <em>src/<em>
  311.    */
  312.   void assign(const typename BitmaskPOD<size>::Data & src);
  313.   /**
  314.    * assign - Set all bits in <em>dst</em> to corresponding in <em>src/<em>
  315.    */
  316.   static void assign(Uint32 dst[], const Uint32 src[]);
  317.   static void assign(Uint32 dst[], const BitmaskPOD<size> & src);
  318.   void assign(const BitmaskPOD<size> & src);
  319.   /**
  320.    * copy this to <em>dst</em>
  321.    */
  322.   void copyto(unsigned sz, Uint32 dst[]) const;
  323.   
  324.   /**
  325.    * assign <em>this</em> according to <em>src/em>
  326.    */
  327.   void assign(unsigned sz, const Uint32 src[]);
  328.   /**
  329.    * get - Check if bit n is set.
  330.    */
  331.   static bool get(const Uint32 data[], unsigned n);
  332.   bool get(unsigned n) const;
  333.   /**
  334.    * set - Set bit n to given value (true/false).
  335.    */
  336.   static void set(Uint32 data[], unsigned n, bool value);
  337.   void set(unsigned n, bool value);
  338.   /**
  339.    * set - Set bit n.
  340.    */
  341.   static void set(Uint32 data[], unsigned n);
  342.   void set(unsigned n);
  343.   /**
  344.    * set - set all bits.
  345.    */
  346.   static void set(Uint32 data[]);
  347.   void set();
  348.   /**
  349.    * clear - Clear bit n.
  350.    */
  351.   static void clear(Uint32 data[], unsigned n);
  352.   void clear(unsigned n);
  353.   /**
  354.    * clear - Clear all bits.
  355.    */
  356.   static void clear(Uint32 data[]);
  357.   void clear();
  358.   /**
  359.    * isclear -  Check if all bits are clear.  This is faster
  360.    * than checking count() == 0.
  361.    */
  362.   static bool isclear(const Uint32 data[]);
  363.   bool isclear() const;
  364.   /**
  365.    * count - Count number of set bits.
  366.    */
  367.   static unsigned count(const Uint32 data[]);
  368.   unsigned count() const;
  369.   /**
  370.    * find - Find first set bit, starting at given position.
  371.    * Returns NotFound when not found.
  372.    */
  373.   static unsigned find(const Uint32 data[], unsigned n);
  374.   unsigned find(unsigned n) const;
  375.   /**
  376.    * equal - Bitwise equal.
  377.    */
  378.   static bool equal(const Uint32 data[], const Uint32 data2[]);
  379.   bool equal(const BitmaskPOD<size>& mask2) const;
  380.   /**
  381.    * bitOR - Bitwise (x | y) into first operand.
  382.    */
  383.   static void bitOR(Uint32 data[], const Uint32 data2[]);
  384.   BitmaskPOD<size>& bitOR(const BitmaskPOD<size>& mask2);
  385.   /**
  386.    * bitAND - Bitwise (x & y) into first operand.
  387.    */
  388.   static void bitAND(Uint32 data[], const Uint32 data2[]);
  389.   BitmaskPOD<size>& bitAND(const BitmaskPOD<size>& mask2);
  390.   /**
  391.    * bitANDC - Bitwise (x & ~y) into first operand.
  392.    */
  393.   static void bitANDC(Uint32 data[], const Uint32 data2[]);
  394.   BitmaskPOD<size>& bitANDC(const BitmaskPOD<size>& mask2);
  395.   /**
  396.    * bitXOR - Bitwise (x ^ y) into first operand.
  397.    */
  398.   static void bitXOR(Uint32 data[], const Uint32 data2[]);
  399.   BitmaskPOD<size>& bitXOR(const BitmaskPOD<size>& mask2);
  400.   /**
  401.    * bitXORC - Bitwise (x ^ ~y) into first operand.
  402.    */
  403.   static void bitXORC(Uint32 data[], const Uint32 data2[]);
  404.   BitmaskPOD<size>& bitXORC(const BitmaskPOD<size>& mask2);
  405.   /**
  406.    * contains - Check if all bits set in data2 (that) are also set in data (this)
  407.    */
  408.   static bool contains(Uint32 data[], const Uint32 data2[]);
  409.   bool contains(BitmaskPOD<size> that);
  410.   /**
  411.    * overlaps - Check if any bit set in this BitmaskPOD (data) is also set in that (data2)
  412.    */
  413.   static bool overlaps(Uint32 data[], const Uint32 data2[]);
  414.   bool overlaps(BitmaskPOD<size> that);
  415.   /**
  416.    * getText - Return as hex-digits (only for debug routines).
  417.    */
  418.   static char* getText(const Uint32 data[], char* buf);
  419.   char* getText(char* buf) const;
  420. };
  421. template <unsigned size>
  422. inline void
  423. BitmaskPOD<size>::assign(Uint32 dst[], const Uint32 src[])
  424. {
  425.   BitmaskImpl::assign(size, dst, src);
  426. }
  427. template <unsigned size>
  428. inline void
  429. BitmaskPOD<size>::assign(Uint32 dst[], const BitmaskPOD<size> & src)
  430. {
  431.   BitmaskImpl::assign(size, dst, src.rep.data);
  432. }
  433. template <unsigned size>
  434. inline void
  435. BitmaskPOD<size>::assign(const typename BitmaskPOD<size>::Data & src)
  436. {
  437.   BitmaskPOD<size>::assign(rep.data, src.data);
  438. }
  439. template <unsigned size>
  440. inline void
  441. BitmaskPOD<size>::assign(const BitmaskPOD<size> & src)
  442. {
  443.   BitmaskPOD<size>::assign(rep.data, src.rep.data);
  444. }
  445. template <unsigned size>
  446. inline void
  447. BitmaskPOD<size>::copyto(unsigned sz, Uint32 dst[]) const
  448. {
  449.   BitmaskImpl::assign(sz, dst, rep.data);
  450. }
  451. template <unsigned size>
  452. inline void
  453. BitmaskPOD<size>::assign(unsigned sz, const Uint32 src[])
  454. {
  455.   BitmaskImpl::assign(sz, rep.data, src);
  456. }
  457. template <unsigned size>
  458. inline bool
  459. BitmaskPOD<size>::get(const Uint32 data[], unsigned n)
  460. {
  461.   return BitmaskImpl::get(size, data, n);
  462. }
  463. template <unsigned size>
  464. inline bool
  465. BitmaskPOD<size>::get(unsigned n) const
  466. {
  467.   return BitmaskPOD<size>::get(rep.data, n);
  468. }
  469. template <unsigned size>
  470. inline void
  471. BitmaskPOD<size>::set(Uint32 data[], unsigned n, bool value)
  472. {
  473.   BitmaskImpl::set(size, data, n, value);
  474. }
  475. template <unsigned size>
  476. inline void
  477. BitmaskPOD<size>::set(unsigned n, bool value)
  478. {
  479.   BitmaskPOD<size>::set(rep.data, n, value);
  480. }
  481. template <unsigned size>
  482. inline void
  483. BitmaskPOD<size>::set(Uint32 data[], unsigned n)
  484. {
  485.   BitmaskImpl::set(size, data, n);
  486. }
  487. template <unsigned size>
  488. inline void
  489. BitmaskPOD<size>::set(unsigned n)
  490. {
  491.   BitmaskPOD<size>::set(rep.data, n);
  492. }
  493. template <unsigned size>
  494. inline void
  495. BitmaskPOD<size>::set(Uint32 data[])
  496. {
  497.   BitmaskImpl::set(size, data);
  498. }
  499. template <unsigned size>
  500. inline void
  501. BitmaskPOD<size>::set()
  502. {
  503.   BitmaskPOD<size>::set(rep.data);
  504. }
  505. template <unsigned size>
  506. inline void
  507. BitmaskPOD<size>::clear(Uint32 data[], unsigned n)
  508. {
  509.   BitmaskImpl::clear(size, data, n);
  510. }
  511. template <unsigned size>
  512. inline void
  513. BitmaskPOD<size>::clear(unsigned n)
  514. {
  515.   BitmaskPOD<size>::clear(rep.data, n);
  516. }
  517. template <unsigned size>
  518. inline void
  519. BitmaskPOD<size>::clear(Uint32 data[])
  520. {
  521.   BitmaskImpl::clear(size, data);
  522. }
  523. template <unsigned size>
  524. inline void
  525. BitmaskPOD<size>::clear()
  526. {
  527.   BitmaskPOD<size>::clear(rep.data);
  528. }
  529. template <unsigned size>
  530. inline bool
  531. BitmaskPOD<size>::isclear(const Uint32 data[])
  532. {
  533.   return BitmaskImpl::isclear(size, data);
  534. }
  535. template <unsigned size>
  536. inline bool
  537. BitmaskPOD<size>::isclear() const
  538. {
  539.   return BitmaskPOD<size>::isclear(rep.data);
  540. }
  541. template <unsigned size>
  542. unsigned
  543. BitmaskPOD<size>::count(const Uint32 data[])
  544. {
  545.   return BitmaskImpl::count(size, data);
  546. }
  547. template <unsigned size>
  548. inline unsigned
  549. BitmaskPOD<size>::count() const
  550. {
  551.   return BitmaskPOD<size>::count(rep.data);
  552. }
  553. template <unsigned size>
  554. unsigned
  555. BitmaskPOD<size>::find(const Uint32 data[], unsigned n)
  556. {
  557.   return BitmaskImpl::find(size, data, n);
  558. }
  559. template <unsigned size>
  560. inline unsigned
  561. BitmaskPOD<size>::find(unsigned n) const
  562. {
  563.   return BitmaskPOD<size>::find(rep.data, n);
  564. }
  565. template <unsigned size>
  566. inline bool
  567. BitmaskPOD<size>::equal(const Uint32 data[], const Uint32 data2[])
  568. {
  569.   return BitmaskImpl::equal(size, data, data2);
  570. }
  571. template <unsigned size>
  572. inline bool
  573. BitmaskPOD<size>::equal(const BitmaskPOD<size>& mask2) const
  574. {
  575.   return BitmaskPOD<size>::equal(rep.data, mask2.rep.data);
  576. }
  577. template <unsigned size>
  578. inline void
  579. BitmaskPOD<size>::bitOR(Uint32 data[], const Uint32 data2[])
  580. {
  581.   BitmaskImpl::bitOR(size,data, data2);
  582. }
  583. template <unsigned size>
  584. inline BitmaskPOD<size>&
  585. BitmaskPOD<size>::bitOR(const BitmaskPOD<size>& mask2)
  586. {
  587.   BitmaskPOD<size>::bitOR(rep.data, mask2.rep.data);
  588.   return *this;
  589. }
  590. template <unsigned size>
  591. inline void
  592. BitmaskPOD<size>::bitAND(Uint32 data[], const Uint32 data2[])
  593. {
  594.   BitmaskImpl::bitAND(size,data, data2);
  595. }
  596. template <unsigned size>
  597. inline BitmaskPOD<size>&
  598. BitmaskPOD<size>::bitAND(const BitmaskPOD<size>& mask2)
  599. {
  600.   BitmaskPOD<size>::bitAND(rep.data, mask2.rep.data);
  601.   return *this;
  602. }
  603. template <unsigned size>
  604. inline void
  605. BitmaskPOD<size>::bitANDC(Uint32 data[], const Uint32 data2[])
  606. {
  607.   BitmaskImpl::bitANDC(size,data, data2);
  608. }
  609. template <unsigned size>
  610. inline BitmaskPOD<size>&
  611. BitmaskPOD<size>::bitANDC(const BitmaskPOD<size>& mask2)
  612. {
  613.   BitmaskPOD<size>::bitANDC(rep.data, mask2.rep.data);
  614.   return *this;
  615. }
  616. template <unsigned size>
  617. inline void
  618. BitmaskPOD<size>::bitXOR(Uint32 data[], const Uint32 data2[])
  619. {
  620.   BitmaskImpl::bitXOR(size,data, data2);
  621. }
  622. template <unsigned size>
  623. inline BitmaskPOD<size>&
  624. BitmaskPOD<size>::bitXOR(const BitmaskPOD<size>& mask2)
  625. {
  626.   BitmaskPOD<size>::bitXOR(rep.data, mask2.rep.data);
  627.   return *this;
  628. }
  629. template <unsigned size>
  630. inline void
  631. BitmaskPOD<size>::bitXORC(Uint32 data[], const Uint32 data2[])
  632. {
  633.   BitmaskImpl::bitXORC(size,data, data2);
  634. }
  635. template <unsigned size>
  636. inline BitmaskPOD<size>&
  637. BitmaskPOD<size>::bitXORC(const BitmaskPOD<size>& mask2)
  638. {
  639.   BitmaskPOD<size>::bitXORC(rep.data, mask2.rep.data);
  640.   return *this;
  641. }
  642. template <unsigned size>
  643. char *
  644. BitmaskPOD<size>::getText(const Uint32 data[], char* buf)
  645. {
  646.   return BitmaskImpl::getText(size, data, buf);
  647. }
  648. template <unsigned size>
  649. inline char *
  650. BitmaskPOD<size>::getText(char* buf) const
  651. {
  652.   return BitmaskPOD<size>::getText(rep.data, buf);
  653. }
  654. template <unsigned size>
  655. inline bool
  656. BitmaskPOD<size>::contains(Uint32 data[], const Uint32 data2[])
  657. {
  658.   return BitmaskImpl::contains(size, data, data2);
  659. }
  660. template <unsigned size>
  661. inline bool
  662. BitmaskPOD<size>::contains(BitmaskPOD<size> that)
  663. {
  664.   return BitmaskPOD<size>::contains(this->rep.data, that.rep.data);
  665. }
  666. template <unsigned size>
  667. inline bool
  668. BitmaskPOD<size>::overlaps(Uint32 data[], const Uint32 data2[])
  669. {
  670.   return BitmaskImpl::overlaps(size, data, data2);
  671. }
  672. template <unsigned size>
  673. inline bool
  674. BitmaskPOD<size>::overlaps(BitmaskPOD<size> that)
  675. {
  676.   return BitmaskPOD<size>::overlaps(this->rep.data, that.rep.data);
  677. }
  678. template <unsigned size>
  679. class Bitmask : public BitmaskPOD<size> {
  680. public:
  681.   Bitmask() { this->clear();}
  682. };
  683. #endif