Ignore:
Timestamp:
Nov 22, 2017, 3:32:58 PM (22 months ago)
Author:
nmedfort
Message:

Improvements to memory usage of CCs

File:
1 edited

Legend:

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

    r5740 r5742  
    112112   
    113113    bool intersects(const UnicodeSet & other) const;
     114
     115    bool subset(const UnicodeSet & other) const;
    114116   
    115117    void insert(const codepoint_t cp);
     
    140142    bool operator<(const UnicodeSet & other) const;
    141143
    142     UnicodeSet(run_type_t emptyOrFull = Empty);
    143     UnicodeSet(const codepoint_t codepoint);
    144     UnicodeSet(const codepoint_t lo, const codepoint_t hi);
    145     UnicodeSet(const UnicodeSet & other);
    146     UnicodeSet(std::initializer_list<run_t> r, std::initializer_list<bitquad_t> q);
    147     UnicodeSet(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end);
    148     UnicodeSet(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end);
     144    UnicodeSet(run_type_t emptyOrFull = Empty, ProxyAllocator<> allocator = GlobalAllocator);
     145    UnicodeSet(const codepoint_t codepoint, ProxyAllocator<> allocator = GlobalAllocator);
     146    UnicodeSet(const codepoint_t lo, const codepoint_t hi, ProxyAllocator<> allocator = GlobalAllocator);
     147    UnicodeSet(const UnicodeSet & other, ProxyAllocator<> allocator = GlobalAllocator);
     148    UnicodeSet(std::initializer_list<run_t> r, std::initializer_list<bitquad_t> q, ProxyAllocator<> allocator = GlobalAllocator);
     149    UnicodeSet(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end, ProxyAllocator<> allocator = GlobalAllocator);
     150    UnicodeSet(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end, ProxyAllocator<> allocator = GlobalAllocator);
    149151   
    150152    inline void swap(UnicodeSet & other);
    151153    inline void swap(UnicodeSet && other);
    152154
     155    inline static void Reset() {
     156        GlobalAllocator.Reset();
     157    }
     158
    153159protected:
    154160
    155     UnicodeSet(std::vector<run_t> && r, std::vector<bitquad_t> && q);
    156 
     161    UnicodeSet(std::vector<run_t> && r, std::vector<bitquad_t> && q, ProxyAllocator<> allocator = GlobalAllocator);
     162   
    157163    class quad_iterator : public boost::iterator_facade<quad_iterator, quad_iterator_return_t, boost::random_access_traversal_tag, quad_iterator_return_t> {
    158164        friend class UnicodeSet;
    159165        friend class boost::iterator_core_access;
    160166    public:
    161         quad_iterator(RunIterator runIterator, RunIterator runEnd, QuadIterator quadIterator, QuadIterator quadEnd, const run_type_t type, const length_t remaining)
     167        explicit quad_iterator(RunIterator runIterator, RunIterator runEnd, QuadIterator quadIterator, QuadIterator quadEnd, const run_type_t type, const length_t remaining)
    162168        : mRunIterator(runIterator)
    163169        , mRunEnd(runEnd)
     
    167173        #endif
    168174        , mType(type)
    169         , mRemaining(remaining) {}
     175        , mRemaining(remaining) {
     176            assert (type == Empty || type == Mixed || type == Full);
     177            assert (remaining > 0 || type == Empty);
     178            assert (remaining <= UNICODE_MAX);
     179        }
    170180
    171181        void advance(unsigned n);
     
    210220
    211221    inline quad_iterator quad_begin() const {
    212         return quad_iterator(mRuns.cbegin(), mRuns.cend(), mQuads.cbegin(), mQuads.cend(), std::get<0>(*mRuns.cbegin()), std::get<1>(*mRuns.cbegin()));
     222        assert (mRuns.cbegin() != mRuns.cend());
     223        return quad_iterator(mRuns.cbegin(), mRuns.cend(), mQuads.cbegin(), mQuads.cend(), mRuns.cbegin()->first, mRuns.cbegin()->second);
    213224    }
    214225
     
    221232    RunVector               mRuns;
    222233    QuadVector              mQuads;
    223     static SlabAllocator<>  mAllocator;
     234    static SlabAllocator<>  GlobalAllocator;
    224235};
    225236
Note: See TracChangeset for help on using the changeset viewer.