本文整理汇总了C++中ContainerT类的典型用法代码示例。如果您正苦于以下问题:C++ ContainerT类的具体用法?C++ ContainerT怎么用?C++ ContainerT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContainerT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replace_ellipsis
void replace_ellipsis (std::vector<ContainerT> const &arguments,
typename ContainerT::size_type index,
ContainerT &expanded, PositionT const &pos)
{
using namespace cpplexer;
typedef typename ContainerT::value_type token_type;
token_type comma(T_COMMA, ",", pos);
for (/**/; index < arguments.size(); ++index) {
ContainerT const &arg = arguments[index];
std::copy(arg.begin(), arg.end(),
std::inserter(expanded, expanded.end()));
if (index < arguments.size()-1)
expanded.push_back(comma);
}
}
示例2: found_unknown_directive
bool
found_unknown_directive(ContextT const& ctx, ContainerT const& line,
ContainerT& pending)
{
BOOST_WAVETEST_OSSTREAM strm;
strm << "21: " << repr((*line.begin()).get_position()) << ": "
<< boost::wave::util::impl::as_string(line) << std::endl;
hooks_trace += BOOST_WAVETEST_GETSTRING(strm);
return false;
}
示例3: trim_replacement_list
inline void
trim_replacement_list (ContainerT &replacement_list)
{
using namespace boost::wave;
// strip leading whitespace
if (replacement_list.size() > 0) {
typename ContainerT::iterator end = replacement_list.end();
typename ContainerT::iterator it = replacement_list.begin();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
if (T_PLACEHOLDER != token_id(*it)) {
typename ContainerT::iterator next = it;
++next;
replacement_list.erase(it);
it = next;
}
else {
++it;
}
}
}
// strip trailing whitespace
if (replacement_list.size() > 0) {
typename ContainerT::reverse_iterator rend = replacement_list.rend();
typename ContainerT::reverse_iterator rit = replacement_list.rbegin();
while (rit != rend && IS_CATEGORY(*rit, WhiteSpaceTokenType))
++rit;
typename ContainerT::iterator end = replacement_list.end();
typename ContainerT::iterator it = rit.base();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
if (T_PLACEHOLDER != token_id(*it)) {
typename ContainerT::iterator next = it;
++next;
replacement_list.erase(it);
it = next;
}
else {
++it;
}
}
}
}
示例4: parameters_equal
inline bool
parameters_equal(ContainerT const ¶meters, ContainerT const &new_parameters)
{
if (parameters.size() != new_parameters.size())
return false; // different parameter count
typedef typename ContainerT::const_iterator const_iterator_type;
const_iterator_type first1 = parameters.begin();
const_iterator_type last1 = parameters.end();
const_iterator_type first2 = new_parameters.begin();
const_iterator_type last2 = new_parameters.end();
while (first1 != last1 && first2 != last2) {
// parameters are different, if the corresponding tokens are different
using namespace boost::wave;
if (token_id(*first1) != token_id(*first2) ||
(*first1).get_value() != (*first2).get_value())
{
break;
}
++first1;
++first2;
}
return (first1 == last1 && first2 == last2) ? true : false;
}
示例5: found_unknown_directive
bool
found_unknown_directive(ContextT const& ctx, ContainerT const& line,
ContainerT& pending)
{
namespace wave = boost::wave;
typedef typename ContainerT::const_iterator iterator_type;
iterator_type it = line.begin();
wave::token_id id = wave::util::impl::skip_whitespace(it, line.end());
if (id != wave::T_IDENTIFIER)
return false; // nothing we could do
if ((*it).get_value() == "version" || (*it).get_value() == "extension")
{
// handle #version and #extension directives
std::copy(line.begin(), line.end(), std::back_inserter(pending));
return true;
}
return false; // unknown directive
}
示例6: definition_equals
inline bool
definition_equals(ContainerT const &definition,
ContainerT const &new_definition)
{
typedef typename ContainerT::const_iterator const_iterator_type;
const_iterator_type first1 = definition.begin();
const_iterator_type last1 = definition.end();
const_iterator_type first2 = new_definition.begin();
const_iterator_type last2 = new_definition.end();
while (first1 != last1 && first2 != last2 && token_equals(*first1, *first2))
{
// skip whitespace, if both sequences have a whitespace next
token_id id1 = next_token<const_iterator_type>::peek(first1, last1, false);
token_id id2 = next_token<const_iterator_type>::peek(first2, last2, false);
if (IS_CATEGORY(id1, WhiteSpaceTokenType) &&
IS_CATEGORY(id2, WhiteSpaceTokenType))
{
// all consecutive whitespace tokens count as one whitespace
// adjust first1 and first2 accordingly
skip_whitespace(first1, last1);
skip_whitespace(first2, last2);
}
else if (!IS_CATEGORY(id1, WhiteSpaceTokenType) &&
!IS_CATEGORY(id2, WhiteSpaceTokenType))
{
++first1;
++first2;
}
else {
// the sequences differ
break;
}
}
return (first1 == last1 && first2 == last2) ? true : false;
}
示例7: tokenize
void tokenize(const std::string& str, ContainerT& tokens, const std::string& delimiters, const bool trimEmpty)
{
/*
I usually choose to use std::vector<std::string> types as my second parameter
(ContainerT)... but list<> is way faster than vector<> for when direct access
is not needed, and you can even create your own string class and use something
like std::list<SubString> where SubString does not do any copies for incredible speed increases.
It's more than double as fast as the fastest tokenize on this page and almost 5 times
faster than some others. Also with the perfect parameter types you can eliminate all string and list copies.
Additionally it does not do the (extremely inefficient) return of result, but rather
it passes the tokens as a reference, thus also allowing you to build up tokens using
multiple calls if you so wished.Lastly it allows you to specify whether to trim empty
tokens from the results via a last optional parameter.All it needs is std::string...
the rest are optional. It does not use streams or the boost library, but is flexible
enough to be able to accept some of these foreign types naturally.
*/
std::string::size_type pos, lastPos = 0;
while(true)
{
pos = str.find_first_of(delimiters, lastPos);
if(pos == std::string::npos)
{
pos = str.length();
if(pos != lastPos || !trimEmpty)
{
tokens.push_back(typename ContainerT::value_type(str.data()+lastPos, typename ContainerT::value_type::size_type(pos-lastPos)));
}
break;
}
else
{
if(pos != lastPos || !trimEmpty)
tokens.push_back(typename ContainerT::value_type(str.data()+lastPos, typename ContainerT::value_type::size_type(pos-lastPos )));
}
lastPos = pos + 1;
}
}
示例8: tokenize
void tokenize(const std::string& str, ContainerT& tokens,
const std::string& delimiters = " ", const bool trimEmpty = false)
{
std::string::size_type pos, lastPos = 0;
while (true)
{
pos = str.find_first_of(delimiters, lastPos);
if (pos == std::string::npos)
{
pos = str.length();
if (pos != lastPos || !trimEmpty)
tokens.push_back(typename ContainerT::value_type(str.data() + lastPos, pos - lastPos));
break;
}
else
{
if (pos != lastPos || !trimEmpty)
tokens.push_back(typename ContainerT::value_type(str.data() + lastPos, pos - lastPos));
}
lastPos = pos + 1;
}
};
示例9: push_front_test
void push_front_test()
{
using namespace boost::spirit;
const char* cp = "one,two,three";
const char* cp_first = cp;
const char* cp_last = cp + test_impl::string_length(cp);
const char* cp_i[] = {"one","two","three"};;
int i;
ContainerT c;
typename ContainerT::const_iterator it;
scanner<char const*> scan( cp_first, cp_last );
match<> hit;
hit = list_p( (*alpha_p)[ push_front_a(c)] , ch_p(',') ).parse(scan);
BOOST_CHECK(hit);
BOOST_CHECK_EQUAL(scan.first, scan.last);
BOOST_CHECK_EQUAL( c.size(), static_cast<typename ContainerT::size_type>(3));
for (i=2, it = c.begin();i>=0 && it != c.end();--i, ++it)
BOOST_CHECK_EQUAL( cp_i[i], *it);
scan.first = cp;
}
示例10: emit_line_directive
bool
emit_line_directive(ContextT const& ctx, ContainerT &pending,
typename ContextT::token_type const& act_token)
{
if (!need_emit_line_directives(ctx.get_language()) ||
!enable_relative_names_in_line_directives())
{
return false;
}
// emit a #line directive showing the relative filename instead
typename ContextT::position_type pos = act_token.get_position();
unsigned int column = 6;
typedef typename ContextT::token_type result_type;
using namespace boost::wave;
pos.set_column(1);
pending.push_back(result_type(T_PP_LINE, "#line", pos));
pos.set_column(column); // account for '#line'
pending.push_back(result_type(T_SPACE, " ", pos));
// 21 is the max required size for a 64 bit integer represented as a
// string
char buffer[22];
using namespace std; // for some systems sprintf is in namespace std
sprintf (buffer, "%d", pos.get_line());
pos.set_column(++column); // account for ' '
pending.push_back(result_type(T_INTLIT, buffer, pos));
pos.set_column(column += (unsigned int)strlen(buffer)); // account for <number>
pending.push_back(result_type(T_SPACE, " ", pos));
pos.set_column(++column); // account for ' '
std::string file("\"");
boost::filesystem::path filename(
boost::wave::util::create_path(ctx.get_current_relative_filename().c_str()));
using boost::wave::util::impl::escape_lit;
file += escape_lit(boost::wave::util::native_file_string(filename)) + "\"";
pending.push_back(result_type(T_STRINGLIT, file.c_str(), pos));
pos.set_column(column += (unsigned int)file.size()); // account for filename
pending.push_back(result_type(T_GENERATEDNEWLINE, "\n", pos));
return true;
}
示例11: values
WLEExponent::ContainerT WLEExponent::values()
{
ContainerT con;
con.insert( WLEExponent::KILO );
con.insert( WLEExponent::BASE );
con.insert( WLEExponent::CENTI );
con.insert( WLEExponent::MILLI );
con.insert( WLEExponent::MICRO );
con.insert( WLEExponent::NANO );
con.insert( WLEExponent::PICO );
con.insert( WLEExponent::FEMTO );
return con;
}
示例12: DynamicGraph
/**
* Constructs a DynamicGraph from a list of edges sorted by source node id.
*/
template <class ContainerT> DynamicGraph(const NodeIterator nodes, const ContainerT &graph)
{
// we need to cast here because DeallocatingVector does not have a valid const iterator
BOOST_ASSERT(std::is_sorted(const_cast<ContainerT&>(graph).begin(), const_cast<ContainerT&>(graph).end()));
number_of_nodes = nodes;
number_of_edges = static_cast<EdgeIterator>(graph.size());
node_array.resize(number_of_nodes + 1);
EdgeIterator edge = 0;
EdgeIterator position = 0;
for (const auto node : osrm::irange(0u, number_of_nodes))
{
EdgeIterator last_edge = edge;
while (edge < number_of_edges && graph[edge].source == node)
{
++edge;
}
node_array[node].first_edge = position;
node_array[node].edges = edge - last_edge;
position += node_array[node].edges;
}
node_array.back().first_edge = position;
edge_list.reserve(static_cast<std::size_t>(edge_list.size() * 1.1));
edge_list.resize(position);
edge = 0;
for (const auto node : osrm::irange(0u, number_of_nodes))
{
for (const auto i : osrm::irange(node_array[node].first_edge,
node_array[node].first_edge + node_array[node].edges))
{
edge_list[i].target = graph[edge].target;
BOOST_ASSERT(edge_list[i].target < number_of_nodes);
edge_list[i].data = graph[edge].data;
++edge;
}
}
}
示例13: initArgs
void initArgs(ContainerT& cc) {
cc.arg( base::DataSourceBase::shared_ptr(ma1.value) );
cc.arg( base::DataSourceBase::shared_ptr(ma2.value) );
cc.arg( base::DataSourceBase::shared_ptr(ma3.value) );
cc.arg( base::DataSourceBase::shared_ptr(ma4.value) );
}
示例14: containerStr
std::string containerStr (const ContainerT& c, int wrapLengthParam = 0, int numIndentationSpaces = 0)
{
return elemsStr(c.begin(), c.end(), wrapLengthParam, numIndentationSpaces);
}
示例15: find_first
template<class ContainerT, class ValueT> inline
auto find_first(const ContainerT& _container, const ValueT& _value) {
return sq::algo::find_first(_container.begin(), _container.end(), _value);
}