Example #1
0
    void intersect (basic_equivset &rhs_, basic_equivset &overlap_)
    {
        intersect_indexes (rhs_._index_vector, overlap_._index_vector);

        if (!overlap_._index_vector.empty ())
        {
            // Note that the LHS takes priority in order to
            // respect rule ordering priority in the lex spec.
            overlap_._id = _id;
            overlap_._greedy = _greedy;
            overlap_._followpos = _followpos;

            typename node_vector::const_iterator overlap_begin_ =
                overlap_._followpos.begin ();
            typename node_vector::const_iterator overlap_end_ =
                overlap_._followpos.end ();
            typename node_vector::const_iterator rhs_iter_ =
                rhs_._followpos.begin ();
            typename node_vector::const_iterator rhs_end_ =
                rhs_._followpos.end ();

            for (; rhs_iter_ != rhs_end_; ++rhs_iter_)
            {
                node *node_ = *rhs_iter_;

                if (std::find (overlap_begin_, overlap_end_, node_) ==
                    overlap_end_)
                {
                    overlap_._followpos.push_back (node_);
                    overlap_begin_ = overlap_._followpos.begin ();
                    overlap_end_ = overlap_._followpos.end ();
                }
            }

            if (_index_vector.empty ())
            {
                _followpos.clear ();
            }

            if (rhs_._index_vector.empty ())
            {
                rhs_._followpos.clear ();
            }
        }
    }
Example #2
0
 bool empty () const
 {
     return _index_vector.empty () && _followpos.empty ();
 }
Example #3
0
 void append_lastpos (node_vector &lastpos_) const
 {
     lastpos_.insert (lastpos_.end (),
                      _lastpos.begin (), _lastpos.end ());
 }
Example #4
0
 void append_firstpos (node_vector &firstpos_) const
 {
     firstpos_.insert (firstpos_.end (),
                       _firstpos.begin (), _firstpos.end ());
 }