本文整理汇总了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;
}
示例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);
}
}
}
示例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);
}
}
}