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


C++ ArraySet::begin方法代码示例

本文整理汇总了C++中ArraySet::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ArraySet::begin方法的具体用法?C++ ArraySet::begin怎么用?C++ ArraySet::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArraySet的用法示例。


在下文中一共展示了ArraySet::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitSelfWithArraySet

void ArraySet::InitSelfWithArraySet( const ArraySet& inSet )
{	
	// A new array will get the size EXACTLY as the number of items in the inSet.
	// i.e. we do not copy empty space. 
	vuint32 inItems = inSet.get_Count();

	InitSelf( inItems );

	memcpy( mpStart, inSet.begin(), inItems * sizeof(ID_TYPE) );
	mpFinish = mpStart + inItems;

	mIsSorted = inSet.mIsSorted;
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例2: ComputeConnectedComponents

void GraphTools::ComputeConnectedComponents(IsolatesType const &isolates, vector<vector<int>> &vComponents, size_t const uNumVertices) {
    ArraySet remaining = isolates.GetInGraph();

    ArraySet currentSearch(uNumVertices);
    vector<bool> evaluated(uNumVertices, 0);

    size_t componentCount(0);
    vComponents.clear();

    if (!remaining.Empty()) {
        int const startVertex = *remaining.begin();
        currentSearch.Insert(startVertex);
        remaining.Remove(startVertex);
        componentCount++;
        vComponents.resize(componentCount);
    }

    while (!remaining.Empty() && !currentSearch.Empty()) {
        int const nextVertex(*currentSearch.begin());
        evaluated[nextVertex] = true;
        vComponents[componentCount - 1].push_back(nextVertex);
        currentSearch.Remove(nextVertex);
        remaining.Remove(nextVertex);
        for (int const neighbor : isolates.Neighbors()[nextVertex]) {
            if (!evaluated[neighbor]) {
                currentSearch.Insert(neighbor);
            }
        }

        if (currentSearch.Empty() && !remaining.Empty()) {
            int const startVertex = *remaining.begin();
            currentSearch.Insert(startVertex);
            remaining.Remove(startVertex);
            componentCount++;
            vComponents.resize(componentCount);
        }
    }
}
开发者ID:sebalamm,项目名称:quick-cliques,代码行数:38,代码来源:GraphTools.cpp

示例3: ComputeConnectedComponents

void GraphTools::ComputeConnectedComponents(vector<vector<int>> const &adjacencyList, vector<vector<int>> &vComponents) {

    vComponents.clear();
    if (adjacencyList.empty()) return;


    size_t componentCount(0);
    size_t uNumVertices(adjacencyList.size());

    vector<bool> evaluated    (uNumVertices, false);
    ArraySet     currentSearch(uNumVertices);
    ArraySet     remaining    (uNumVertices);

    for (int vertex = 0; vertex < uNumVertices; ++vertex) {
        remaining.Insert(vertex);
    }

    // add first vertex, from where we start search
    int const startVertex(0);
    currentSearch.Insert(startVertex);
    remaining.Remove(startVertex);
    componentCount++;
    vComponents.resize(componentCount);

    while (!remaining.Empty() && !currentSearch.Empty()) {
        int const nextVertex(*currentSearch.begin());
        evaluated[nextVertex] = true;
        vComponents[componentCount - 1].push_back(nextVertex);
        currentSearch.Remove(nextVertex);
        remaining.Remove(nextVertex);
        for (int const neighbor : adjacencyList[nextVertex]) {
            if (!evaluated[neighbor]) {
                currentSearch.Insert(neighbor);
            }
        }

        if (currentSearch.Empty() && !remaining.Empty()) {
            int const startVertex = *remaining.begin();
            currentSearch.Insert(startVertex);
            remaining.Remove(startVertex);
            componentCount++;
            vComponents.resize(componentCount);
        }
    }
}
开发者ID:darrenstrash,项目名称:kernel-mis,代码行数:45,代码来源:GraphTools.cpp


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