Changeset 1994


Ignore:
Timestamp:
Apr 1, 2012, 7:15:44 AM (7 years ago)
Author:
cameron
Message:

move_to methods for scanners

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock_scan.hpp

    r1985 r1994  
    6969        }
    7070
     71        /* Set or reset the iterator to position new_pos. */
     72        IDISA_ALWAYS_INLINE void move_to(uint32_t new_pos) {
     73                const scanblock_t one_bit = 1;
     74                this->blk = new_pos / (sizeof(scanblock_t)*8);
     75                this->pos = new_pos % (sizeof(scanblock_t)*8);
     76                this->scan_blk = ((scanblock_t *)this->strm)[this->blk];
     77                // clear bit at pos and all positions to the right.
     78                scanblock_t marker = one_bit << this->pos;
     79                this->scan_blk = this->scan_blk &~((marker-1)|marker);
     80        }
     81
    7182        IDISA_ALWAYS_INLINE bool is_done() {return (-1==this->pos);}
    7283        IDISA_ALWAYS_INLINE void set_strm(const bitblock_t * strm) {this->strm = strm;}
     
    109120        }
    110121
     122        /* Set or reset the iterator to position new_pos. */
     123        IDISA_ALWAYS_INLINE void move_to(uint32_t new_pos) {
     124                const scanblock_t one_bit = 1;
     125                this->blk = new_pos / (sizeof(scanblock_t)*8);
     126                this->pos = new_pos % (sizeof(scanblock_t)*8);
     127                this->scan_blk = ((scanblock_t *)this->strm)[this->blk];
     128                // clear bit at pos and all positions to the left.
     129                scanblock_t marker = one_bit << this->pos;
     130                this->scan_blk = this->scan_blk &(marker-1);
     131        }
     132
    111133        IDISA_ALWAYS_INLINE bool is_done() {return (-1==this->pos);}
    112134        IDISA_ALWAYS_INLINE void set_strm(const bitblock_t * strm) {this->strm = strm;}
Note: See TracChangeset for help on using the changeset viewer.