void separate_interval_set<DomainT,Interval,Compare,Alloc>::insert(const value_type& x) { if(x.empty()) return; std::pair<typename ImplSetT::iterator,bool> insertion = this->_set.insert(x); if(insertion.WAS_SUCCESSFUL) handle_neighbours(insertion.ITERATOR); else { typename ImplSetT::iterator fst_it = this->_set.lower_bound(x); typename ImplSetT::iterator end_it = this->_set.upper_bound(x); typename ImplSetT::iterator it=fst_it, nxt_it=fst_it, victim; Interval<DomainT> leftResid; (*it).left_surplus(leftResid,x); Interval<DomainT> rightResid; while(it!=end_it) { if((++nxt_it)==end_it) (*it).right_surplus(rightResid,x); victim = it; it++; this->_set.erase(victim); } Interval<DomainT> extended = x; extended.extend(leftResid).extend(rightResid); extended.extend(rightResid); insert(extended); } }
//! Formatting operator result_type operator() (stream_type& strm, value_type const& scopes) const { if (!scopes.empty()) { if (m_direction == expressions::forward) format_forward(strm, scopes); else format_reverse(strm, scopes); } else { strm << m_empty_marker; } }
bool parameters::then_else( bool expr, value_type const &s, value_type::size_type *pos, value_type *replacement ) const { value_type::value_type c = s[ *pos ]; bool found_param = false, not_empty = false; switch ( c ) { case_123456789: found_param = true; if ( expr ) { *replacement = lookup_param( to_index( c ) ); not_empty = !replacement->empty(); } break; case '{': while ( ++*pos < s.size() ) { c = s[ *pos ]; switch ( c ) { case_123456789: found_param = true; if ( expr ) { value_type const param = lookup_param( to_index( c ) ); not_empty = !param.empty() || not_empty; *replacement += param; } break; case '}': goto done; case '\\': if ( *pos + 1 < s.size() ) c = s[ ++*pos ]; // no break; default: if ( expr ) *replacement += c; } // switch } // while throw invalid_argument( "'}' expected for ?:" ); default: throw invalid_argument( BUILD_STRING( '\'', c, "': invalid character after '", (expr ? '?' : ':'), "' (one of [1-9{] expected)" ) ); } // switch done: return !found_param || not_empty; }
void separate_interval_set<DomainT,Interval,Compare,Alloc>::subtract(const value_type& x) { if(x.empty()) return; typename ImplSetT::iterator fst_it = this->_set.lower_bound(x); if(fst_it==this->_set.end()) return; typename ImplSetT::iterator end_it = this->_set.upper_bound(x); typename ImplSetT::iterator it=fst_it, nxt_it=fst_it, victim; interval_type leftResid; (*it).left_surplus(leftResid,x); interval_type rightResid; while(it!=end_it) { if((++nxt_it)==end_it) (*it).right_surplus(rightResid,x); victim = it; it++; this->_set.erase(victim); } insert(leftResid); insert(rightResid); }
bool IsEmpty() const { return value.empty(); }
static typename boost::disable_if<Clearable>::type fork_clear_check(value_type const& value) { if (value.empty()) throw(restricted_string_nonconformance("空に変更できません")); }
static void conform_check(value_type const& value) { if (!value.empty() && !is_conform(value)) throw(restricted_string_nonconformance("制限に適合しません")); }
bool empty() const { return value_.empty(); }