本文整理汇总了C++中ContainerT::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerT::size方法的具体用法?C++ ContainerT::size怎么用?C++ ContainerT::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerT
的用法示例。
在下文中一共展示了ContainerT::size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
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;
}
示例2: _copyData
void _copyData(const ContainerT& data, ResultT*& result)
{
if(data.size() == 0)
{
return;
}
result = new ResultT[data.size()];
std::copy(data.begin(), data.end(), result);
}
示例3: DynamicGraph
template <class ContainerT> DynamicGraph(const NodeIterator nodes, const ContainerT &graph)
{
number_of_nodes = nodes;
number_of_edges = (EdgeIterator)graph.size();
node_list.reserve(number_of_nodes + 1);
node_list.resize(number_of_nodes + 1);
EdgeIterator edge = 0;
EdgeIterator position = 0;
for (const auto node : osrm::irange(0u, number_of_nodes))
{
EdgeIterator lastEdge = edge;
while (edge < number_of_edges && graph[edge].source == node)
{
++edge;
}
node_list[node].firstEdge = position;
node_list[node].edges = edge - lastEdge;
position += node_list[node].edges;
}
node_list.back().firstEdge = 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_list[node].firstEdge,
node_list[node].firstEdge + node_list[node].edges))
{
edge_list[i].target = graph[edge].target;
edge_list[i].data = graph[edge].data;
++edge;
}
}
}
示例4: StaticGraph
template <typename ContainerT> StaticGraph(const int nodes, const ContainerT &graph)
{
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 : irange(0u, number_of_nodes + 1))
{
EdgeIterator last_edge = edge;
while (edge < number_of_edges && graph[edge].source == node)
{
++edge;
}
node_array[node].first_edge = position; //=edge
position += edge - last_edge; // remove
}
edge_array.resize(position); //(edge)
edge = 0;
for (const auto node : irange(0u, number_of_nodes))
{
EdgeIterator e = node_array[node + 1].first_edge;
for (const auto i : irange(node_array[node].first_edge, e))
{
edge_array[i].target = graph[edge].target;
edge_array[i].data = graph[edge].data;
edge++;
}
}
}
示例5:
inline void
trim_sequence_right (ContainerT &argument)
{
using namespace boost::wave;
// strip trailing whitespace (should be only one token)
if (argument.size() > 0 &&
IS_CATEGORY(argument.back(), WhiteSpaceTokenType))
{
argument.pop_back();
}
}
示例6:
inline void
trim_argument_left (ContainerT &argument)
{
using namespace boost::wave;
// strip leading whitespace (should be only one token)
if (argument.size() > 0 &&
IS_CATEGORY(argument.front(), WhiteSpaceTokenType))
{
argument.pop_front();
}
}
示例7: selection_sort
inline void selection_sort(ContainerT &container) noexcept {
const size_t containerSize = container.size();
for (size_t i = 0; i < containerSize - 1; ++i) {
size_t elemIndex = i;
for (int j = i; j < containerSize; ++j) {
if (container.at(elemIndex) > container.at(j)) {
elemIndex = j;
}
}
algorithm::swap(container.at(i), container.at(elemIndex));
}
}
示例8: 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;
}
示例9: 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;
}
}
}
示例10: insertion_sort_recursive
inline void insertion_sort_recursive(ContainerT &container) noexcept {
detail::_insertion_sort_recursive(container, container.size() - 1, container.size() - 1);;
}