inline void trim_left_if(SequenceT& Input)
{
    Input.erase( 
        Input.begin(),
        trim_begin( 
            Input.begin(), 
            Input.end() )
        );
}
inline void trim_right_if(SequenceT& Input)
{
    Input.erase(
        trim_end( 
            Input.begin(), 
            Input.end() ),
        Input.end()
        );
}
Example #3
0
SequenceT Intersperse(const typename SequenceT::value_type & elem, const SequenceT & sequence) 
{

	if( sequence.size() <= 1 ) return sequence;

	SequenceT newSequence;
	for( const typename SequenceT::value_type & t : sequence ) {
		newSequence.push_back(t);
		newSequence.push_back(elem);
	}

	// Remove the last occurence of elem from the end of the new sequence.
	newSequence.pop_back();

	return newSequence;
}
Example #4
0
 inline void trim_left_if(SequenceT& Input, PredicateT IsSpace)
 {
     Input.erase( 
         ::boost::begin(Input),
         ::boost::algorithm::detail::trim_begin( 
             ::boost::begin(Input), 
             ::boost::end(Input), 
             IsSpace));
 }
Example #5
0
 inline void trim_right_if(SequenceT& Input, PredicateT IsSpace)
 {
     Input.erase(
         ::mars_boost::algorithm::detail::trim_end( 
             ::mars_boost::begin(Input), 
             ::mars_boost::end(Input), 
             IsSpace ),
         ::mars_boost::end(Input)
         );
 }
Example #6
0
		void SaveData(SequenceT& buf) const
		{
			switch (_type)
			{
			case OBJTYPE_INTEGER:
				buf.append((typename SequenceT::value_type const*)&_i, sizeof(uint32_t));
				break;
			case OBJTYPE_REAL:
			case OBJTYPE_UNREAL:
				buf.append((typename SequenceT::value_type const*)&_f, sizeof(float));
				break;
			case OBJTYPE_STRING:
				buf.append(_s);
				buf.push_back('\0');
				break;
			default:
				throw base::exception("Unexpected data type: %d.", _type);
				break;
			}
		}
Example #7
0
std::string longestCommonPrefix(const SequenceT& strings)
{
    if (strings.empty())
        return "";

    typename SequenceT::const_iterator itr = strings.begin();
    std::string result = *itr;
    for (++itr; itr != strings.end(); ++itr)
    {
        const std::string& target = *itr;

        if (result.empty())
            return "";

        for (size_t j=0; j < target.length() && j < result.length(); ++j)
            if (target[j] != result[j])
            {
                result.resize(j);
                break;
            }
    }
    return result;
}
void print_sequence(string name, const SequenceT<T> & printMe) {
  print_info(name,printMe);
  typename SequenceT<T>::const_iterator i;
  for (i = printMe.begin(); i != printMe.end(); ++i)
    cout << '\t' << "SequenceT[" << "] is (" << *i << ")" << endl;
}
void print_info(string name, const SequenceT<T> & printMe) {
  cout << "PRINTING " << name << ":" << "which has size(" << printMe.size() << ")"
    << " and cap(" << printMe.capacity() << ")" << endl;
}