Ignore:
Timestamp:
Jun 25, 2015, 3:47:56 PM (4 years ago)
Author:
nmedfort
Message:

Upload of an untested (inactive) UCD compiler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/unicode_set.h

    r4616 r4617  
    33#include <stdint.h>
    44#include <vector>
     5#include <re/re_cc.h>
    56#include <boost/iterator/iterator_facade.hpp>
    67
     
    4546public:
    4647
    47     class iterator : public boost::iterator_facade<iterator, const UnicodeSet &, boost::forward_traversal_tag, std::pair<RunStructure, bitquad_t>> {
     48    class quad_iterator : public boost::iterator_facade<quad_iterator, const std::pair<RunStructure, bitquad_t>, boost::forward_traversal_tag> {
    4849        friend class UnicodeSet;
    49     public:
    50         iterator(const UnicodeSet & set, unsigned runIndex) : mUnicodeSet(set), mRunIndex(runIndex), mOffset(0), mQuadIndex(0) {}
     50        friend class boost::iterator_core_access;
    5151    protected:
    52         friend class boost::iterator_core_access;
     52        quad_iterator(const UnicodeSet & set, unsigned runIndex) : mUnicodeSet(set), mRunIndex(runIndex), mOffset(0), mQuadIndex(0) {}
     53
    5354        void advance(unsigned n);
     55
    5456        const std::pair<RunStructure, bitquad_t> dereference() const;
     57
    5558        inline void increment() {
    5659            advance(1);
    5760        }
    58         inline bool equal(iterator const& other) const {
    59             return (mRunIndex == other.mRunIndex) && (&(mUnicodeSet) == &(other.mUnicodeSet)) && (mQuadIndex == other.mQuadIndex) && (mOffset == other.mOffset);
     61
     62        inline bool equal(quad_iterator const& other) const {
     63            assert (&(mUnicodeSet) == &(other.mUnicodeSet));
     64            return (mRunIndex == other.mRunIndex) && (mQuadIndex == other.mQuadIndex) && (mOffset == other.mOffset);
    6065        }
    6166    private:
     
    6671    };
    6772
     73    class iterator : public boost::iterator_facade<iterator, re::interval_t, boost::forward_traversal_tag, re::interval_t> {
     74        friend class UnicodeSet;
     75        friend class boost::iterator_core_access;
     76    protected:
     77        iterator(const UnicodeSet & set, unsigned runIndex, unsigned quadIndex)
     78        : mUnicodeSet(set), mRunIndex(runIndex), mQuadIndex(quadIndex), mQuadOffset(0)
     79        , mQuadRunIndex(0), mBaseCodePoint(0), mLeft(0), mRight(0)
     80        {
     81
     82        }
     83
     84        void advance(unsigned n);
     85
     86        re::interval_t dereference() const {
     87            return std::make_pair(mLeft, mRight);
     88        }
     89
     90        inline void increment() {
     91            advance(1);
     92        }
     93
     94        inline bool equal(iterator const & other) const {
     95            assert (&(mUnicodeSet) == &(other.mUnicodeSet));
     96            return (mRunIndex == other.mRunIndex) && (mQuadIndex == other.mQuadIndex) &&
     97                   (mQuadOffset == other.mQuadOffset) && (mQuadRunIndex == other.mQuadRunIndex);
     98        }
     99    private:
     100        const UnicodeSet &      mUnicodeSet;
     101        unsigned                mRunIndex;
     102        unsigned                mQuadIndex;
     103        bitquad_t               mQuadOffset;
     104        unsigned                mQuadRunIndex;
     105        unsigned                mBaseCodePoint;
     106        re::codepoint_t         mLeft;
     107        re::codepoint_t         mRight;
     108    };
     109
     110    inline quad_iterator quad_begin() const {
     111        return quad_iterator(*this, 0);
     112    }
     113
     114    inline quad_iterator quad_end() const {
     115        return quad_iterator(*this, runs.size());
     116    }
     117
    68118    inline iterator begin() const {
    69         return iterator(*this, 0);
     119        return iterator(*this, 0,0);
    70120    }
    71121
    72122    inline iterator end() const {
    73         return iterator(*this, runs.size());
     123        return iterator(*this, runs.size(), quads.size());
    74124    }
    75125
Note: See TracChangeset for help on using the changeset viewer.