annotate DEPENDENCIES/generic/include/boost/xpressive/detail/utility/chset/range_run.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2001-2003 Joel de Guzman
Chris@16 3 http://spirit.sourceforge.net/
Chris@16 4
Chris@16 5 Use, modification and distribution is subject to the Boost Software
Chris@16 6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 =============================================================================*/
Chris@16 9 #ifndef BOOST_XPRESSIVE_SPIRIT_RANGE_RUN_HPP_EAN_10_04_2005
Chris@16 10 #define BOOST_XPRESSIVE_SPIRIT_RANGE_RUN_HPP_EAN_10_04_2005
Chris@16 11
Chris@16 12 ///////////////////////////////////////////////////////////////////////////////
Chris@16 13 #include <vector>
Chris@16 14
Chris@16 15 ///////////////////////////////////////////////////////////////////////////////
Chris@16 16 namespace boost { namespace xpressive { namespace detail
Chris@16 17 {
Chris@16 18
Chris@16 19 ///////////////////////////////////////////////////////////////////////////
Chris@16 20 //
Chris@16 21 // range class
Chris@16 22 //
Chris@16 23 // Implements a closed range of values. This class is used in
Chris@16 24 // the implementation of the range_run class.
Chris@16 25 //
Chris@16 26 // { Low level implementation detail }
Chris@16 27 // { Not to be confused with spirit::range }
Chris@16 28 //
Chris@16 29 ///////////////////////////////////////////////////////////////////////////
Chris@16 30 template<typename Char>
Chris@16 31 struct range
Chris@16 32 {
Chris@16 33 range(Char first, Char last);
Chris@16 34
Chris@16 35 bool is_valid() const;
Chris@16 36 bool includes(Char v) const;
Chris@16 37 bool includes(range const &r) const;
Chris@16 38 bool overlaps(range const &r) const;
Chris@16 39 void merge(range const &r);
Chris@16 40
Chris@16 41 Char first_;
Chris@16 42 Char last_;
Chris@16 43 };
Chris@16 44
Chris@16 45 //////////////////////////////////
Chris@16 46 template<typename Char>
Chris@16 47 struct range_compare
Chris@16 48 {
Chris@16 49 bool operator()(range<Char> const &x, range<Char> const &y) const
Chris@16 50 {
Chris@16 51 return x.first_ < y.first_;
Chris@16 52 }
Chris@16 53 };
Chris@16 54
Chris@16 55 ///////////////////////////////////////////////////////////////////////////
Chris@16 56 //
Chris@16 57 // range_run
Chris@16 58 //
Chris@16 59 // An implementation of a sparse bit (boolean) set. The set uses
Chris@16 60 // a sorted vector of disjoint ranges. This class implements the
Chris@16 61 // bare minimum essentials from which the full range of set
Chris@16 62 // operators can be implemented. The set is constructed from
Chris@16 63 // ranges. Internally, adjacent or overlapping ranges are
Chris@16 64 // coalesced.
Chris@16 65 //
Chris@16 66 // range_runs are very space-economical in situations where there
Chris@16 67 // are lots of ranges and a few individual disjoint values.
Chris@16 68 // Searching is O(log n) where n is the number of ranges.
Chris@16 69 //
Chris@16 70 // { Low level implementation detail }
Chris@16 71 //
Chris@16 72 ///////////////////////////////////////////////////////////////////////////
Chris@16 73 template<typename Char>
Chris@16 74 struct range_run
Chris@16 75 {
Chris@16 76 typedef range<Char> range_type;
Chris@16 77 typedef std::vector<range_type> run_type;
Chris@16 78 typedef typename run_type::iterator iterator;
Chris@16 79 typedef typename run_type::const_iterator const_iterator;
Chris@16 80
Chris@16 81 void swap(range_run& rr);
Chris@16 82 bool empty() const;
Chris@16 83 bool test(Char v) const;
Chris@16 84 template<typename Traits>
Chris@16 85 bool test(Char v, Traits const &tr) const;
Chris@16 86 void set(range_type const &r);
Chris@16 87 void clear(range_type const &r);
Chris@16 88 void clear();
Chris@16 89
Chris@16 90 const_iterator begin() const;
Chris@16 91 const_iterator end() const;
Chris@16 92
Chris@16 93 private:
Chris@16 94 void merge(iterator iter, range_type const &r);
Chris@16 95
Chris@16 96 run_type run_;
Chris@16 97 };
Chris@16 98
Chris@16 99 }}} // namespace boost::xpressive::detail
Chris@16 100
Chris@16 101 #endif
Chris@16 102