Ignore:
Timestamp:
Oct 1, 2015, 2:54:17 PM (4 years ago)
Author:
nmedfort
Message:

Embedded UnicodeSet? into CC objects (will currently cause memory leak)

File:
1 edited

Legend:

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

    r4631 r4812  
    33#include <stdint.h>
    44#include <vector>
    5 #include <re/re_cc.h>
    65#include <boost/iterator/iterator_facade.hpp>
    76
     
    4645    using quad_iterator_return_t = std::pair<run_t, bitquad_t>;
    4746
    48     using codepoint_t = re::codepoint_t;
    49     using interval_t = re::interval_t;
     47    using codepoint_t = unsigned;
     48    using interval_t = std::pair<codepoint_t, codepoint_t>;
     49
    5050    using RunVector = std::vector<run_t>;
    5151    using QuadVector = std::vector<bitquad_t>;
     52
     53    using size_type = RunVector::size_type;
    5254
    5355    class iterator : public boost::iterator_facade<iterator, interval_t, boost::forward_traversal_tag, interval_t> {
     
    112114
    113115        inline run_type_t type() const {
    114             return std::get<0>(*mRunIterator);
     116            return mRunIterator->first;
    115117        }
    116118
    117119        inline length_t length() const {
    118             return std::get<1>(*mRunIterator) - mOffset;
     120            return mRunIterator->second - mOffset;
    119121        }
    120122
     
    145147    bool intersects(const codepoint_t lo, const codepoint_t hi) const;
    146148
     149    inline void insert(const codepoint_t cp) {
     150        *this = std::move(*this + UnicodeSet(cp));
     151    }
     152
     153    inline void insert_range(const codepoint_t lo, const codepoint_t hi) {
     154        *this = std::move(*this + UnicodeSet(lo, hi));
     155    }
     156
     157    bool empty() const;
     158
     159    size_type size() const;
     160
     161    interval_t front() const;
     162
     163    interval_t back() const;
     164
    147165    void dump(llvm::raw_ostream & out) const;
    148166
     
    152170    UnicodeSet operator-(const UnicodeSet & other) const;
    153171    UnicodeSet operator^(const UnicodeSet & other) const;
     172
    154173    inline UnicodeSet & operator=(const UnicodeSet & other) = default;
    155174    inline UnicodeSet & operator=(UnicodeSet && other) = default;
     
    172191};
    173192
     193enum : UnicodeSet::codepoint_t { UNICODE_MAX = 0x10FFFF };
     194
    174195inline void UnicodeSet::swap(UnicodeSet & other) {
    175196    mRuns.swap(other.mRuns); mQuads.swap(other.mQuads);
Note: See TracChangeset for help on using the changeset viewer.