Changeset 1675


Ignore:
Timestamp:
Nov 13, 2011, 12:11:32 PM (7 years ago)
Author:
ksherdy
Message:

Added reset() methods to Forward and Reverse scanner classes to allow re-initialization without object constructor overhead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock_scan.hpp

    r1627 r1675  
    3232// Forward
    3333template <class bitblock_t, class scanblock_t>
    34 class ForwardScanner : Scanner<bitblock_t, scanblock_t> {
     34class ForwardScanner: public Scanner<bitblock_t, scanblock_t> {
    3535
    3636public:
     
    3838        ForwardScanner(): Scanner<bitblock_t, scanblock_t>(){}
    3939        ForwardScanner(bitblock_t * s): Scanner<bitblock_t, scanblock_t>(s, 0, 0, *((scanblock_t *)s)){}
     40
     41        IDISA_ALWAYS_INLINE void reset(bitblock_t * s) {
     42                Scanner<bitblock_t, scanblock_t>::strm = s;
     43                Scanner<bitblock_t, scanblock_t>::pos = 0;
     44                Scanner<bitblock_t, scanblock_t>::blk = 0;
     45                Scanner<bitblock_t, scanblock_t>::scan_blk = *(scanblock_t *)s;
     46        }
    4047
    4148        IDISA_ALWAYS_INLINE uint32_t scan_to_next() {
     
    6370// Reverse
    6471template <class bitblock_t, class scanblock_t>
    65 class ReverseScanner : Scanner<bitblock_t, scanblock_t> {
     72class ReverseScanner: public Scanner<bitblock_t, scanblock_t> {
    6673
    6774public:
    6875        ReverseScanner(): Scanner<bitblock_t, scanblock_t>(){}
    6976        ReverseScanner(bitblock_t * s): Scanner<bitblock_t, scanblock_t>(s, 0, BLOCK_COUNT, *((scanblock_t *)s + (BLOCK_COUNT-1))){}
     77
     78        IDISA_ALWAYS_INLINE void reset(bitblock_t * s) {
     79                Scanner<bitblock_t, scanblock_t>::strm = s;
     80                Scanner<bitblock_t, scanblock_t>::pos = 0;
     81                Scanner<bitblock_t, scanblock_t>::blk = BLOCK_COUNT;
     82                Scanner<bitblock_t, scanblock_t>::scan_blk = *((scanblock_t *)s + (BLOCK_COUNT-1));
     83        }
    7084
    7185        IDISA_ALWAYS_INLINE uint32_t scan_to_next() {
Note: See TracChangeset for help on using the changeset viewer.