Ignore:
Timestamp:
May 16, 2013, 2:41:59 PM (6 years ago)
Author:
ksherdy
Message:

Added isDone method to Forward/Reverse? Iterators. Minor additions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock_iterator.hpp

    r3142 r3148  
    7272//
    7373#define has_bit(x) (x != 0)
     74#define EOS -1
    7475
    7576template <class bitblock_t, class scanblock_t>
     
    7778
    7879protected:
    79         Scanner(): strm(NULL), pos(-1), blk(-1), scan_blk(-1) {}
     80        Scanner(): strm(NULL), pos(EOS), blk(-1), scan_blk(-1) {}
    8081        Scanner(const bitblock_t * s, uint32_t start_pos, uint32_t start_blk, scanblock_t start_scan_blk): strm(s), pos(start_pos), blk(start_blk), scan_blk(start_scan_blk) {}
    8182
     
    116117                };
    117118
    118                 this->pos = -1;
     119                this->pos = EOS;
    119120                return (this->pos);
    120121        }
     
    131132        }
    132133
    133         IDISA_ALWAYS_INLINE bool is_done() {return (-1==this->pos);}
     134        IDISA_ALWAYS_INLINE bool is_done() const {return (EOS==this->pos);}
    134135        IDISA_ALWAYS_INLINE void set_strm(const bitblock_t * strm) {this->strm = strm;}
    135136        IDISA_ALWAYS_INLINE const bitblock_t * get_strm() const {return this->strm;}
    136137        IDISA_ALWAYS_INLINE int32_t get_pos() const {return this->pos;}
    137 
     138        IDISA_ALWAYS_INLINE void set_pos(int32_t pos) {(this->pos = pos);}
    138139        static const int32_t BLOCK_COUNT = sizeof(bitblock_t)/sizeof(scanblock_t);
    139140
     
    175176                };
    176177
    177                 this->pos = -1;
     178                this->pos = EOS;
    178179                return (this->pos);
    179180        }
     
    190191        }
    191192
    192         IDISA_ALWAYS_INLINE bool is_done() {return (-1==this->pos);}
     193        IDISA_ALWAYS_INLINE bool is_done() const {return (EOS==this->pos);}
    193194        IDISA_ALWAYS_INLINE void set_strm(const bitblock_t * strm) {this->strm = strm;}
    194195        IDISA_ALWAYS_INLINE const bitblock_t * get_strm() const {return this->strm;}
    195196        IDISA_ALWAYS_INLINE int32_t get_pos() const {return this->pos;}
    196 
     197        IDISA_ALWAYS_INLINE void set_pos(int32_t pos) {(this->pos = pos);}
    197198        static const uint32_t BLOCK_COUNT = sizeof(bitblock_t)/sizeof(scanblock_t);
    198199
     
    207208{
    208209public:
     210
    209211        ForwardIterator(bitblock_t * s): scanner(s)
    210212        {
     
    212214        }
    213215
     216        // set scanner to first pos of
    214217        void init(bitblock_t * s)
    215218        {
     
    253256        }
    254257
     258        IDISA_ALWAYS_INLINE bool isDone() const
     259        {
     260                return scanner.is_done();
     261        }
     262
    255263protected:
    256264        ForwardIterator() {}
     
    262270class BitBlockForwardIterator: public ForwardIterator<BitBlock, ScanWord> {
    263271public:
     272        BitBlockForwardIterator(){}
    264273        BitBlockForwardIterator(BitBlock * s): ForwardIterator<BitBlock, ScanWord>(s){}
    265 protected:
    266         BitBlockForwardIterator(){}
    267274};
    268275
     
    316323        }
    317324
     325        IDISA_ALWAYS_INLINE bool isDone() const
     326        {
     327                return scanner.is_done();
     328        }
     329
    318330protected:
    319331        ReverseIterator() {}
    320 
    321332        ReverseScanner<bitblock_t, scanblock_t> scanner;
    322333};
    323334
    324 class BitBlockReverseIterator: public ReverseIterator<BitBlock, ScanWord> {
     335class BitBlockReverseIterator: public ReverseIterator<BitBlock, ScanWord>
     336{
    325337public:
    326338        BitBlockReverseIterator(BitBlock * s): ReverseIterator<BitBlock, ScanWord>(s){}
    327339private:
    328340        BitBlockReverseIterator(){}
    329 
    330341};
    331342
     
    336347{
    337348public:
    338         BitStreamIterator():pos(-1), blk(-1), blk_pos(-1), strm(NULL), scan_blk(-1), scan_blk_cnt(0)
    339         {
    340                 // default constructor defines past-the-end of bit stream semantics, pos == -1
     349        BitStreamIterator():pos(EOS), blk(-1), blk_pos(-1), strm(NULL), scan_blk(-1), scan_blk_cnt(0)
     350        {
     351                // default constructor defines past-the-end of bit stream semantics, pos == EOS
    341352        }
    342353
     
    404415        }
    405416        */
     417
     418        IDISA_ALWAYS_INLINE bool isDone() const
     419        {
     420                return (EOS == pos);
     421        }
    406422
    407423        void debug() {
     
    433449                };
    434450
    435                 pos = -1;
     451                pos = EOS;
    436452                return;
    437453        }
     
    492508                };
    493509
    494                 this->pos = -1;
     510                this->pos = EOS;
    495511                return (this->pos);
    496512        }
    497513
    498514
    499         IDISA_ALWAYS_INLINE bool is_done() {return (-1==this->pos);}
     515        IDISA_ALWAYS_INLINE bool is_done() {return (EOS==this->pos);}
    500516        IDISA_ALWAYS_INLINE void set_strm(const bitblock_t * strm) {this->strm = strm;}
    501517        IDISA_ALWAYS_INLINE const bitblock_t * get_strm() const {return this->strm;}
Note: See TracChangeset for help on using the changeset viewer.