当前位置: 首页>>代码示例>>C++>>正文


C++ ContainerT::size方法代码示例

本文整理汇总了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 &parameters, 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;
}
开发者ID:QuentinRougemont,项目名称:MicrosatDemogInference,代码行数:26,代码来源:cpp_macromap_utils.hpp

示例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);
}
开发者ID:zc5872061,项目名称:wonderland,代码行数:9,代码来源:MeshManager.cpp

示例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;
         }
     }
 }
开发者ID:Gozhack,项目名称:osrm-backend,代码行数:34,代码来源:dynamic_graph.hpp

示例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++;
            }
        }
    }
开发者ID:arnekaiser,项目名称:osrm-backend,代码行数:33,代码来源:static_graph.hpp

示例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();
    }
}
开发者ID:QuentinRougemont,项目名称:MicrosatDemogInference,代码行数:12,代码来源:cpp_macromap_utils.hpp

示例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();
    }
}
开发者ID:4eek,项目名称:xtractorfan,代码行数:12,代码来源:cpp_macromap_utils.hpp

示例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));
        }
    }
开发者ID:assemblical,项目名称:algorithms,代码行数:14,代码来源:selection_sort.hpp

示例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;
}
开发者ID:KerwinMa,项目名称:AerothFlyffSource,代码行数:23,代码来源:push_front_test.cpp

示例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;
            }
        }
    }
开发者ID:7890,项目名称:osrm-backend,代码行数:40,代码来源:dynamic_graph.hpp

示例10: insertion_sort_recursive

 inline void insertion_sort_recursive(ContainerT &container) noexcept {
     detail::_insertion_sort_recursive(container, container.size() - 1, container.size() - 1);;
 }
开发者ID:assemblical,项目名称:algorithms,代码行数:3,代码来源:insertion_sort_recursive.hpp


注:本文中的ContainerT::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。