本文整理汇总了C++中ArraySet类的典型用法代码示例。如果您正苦于以下问题:C++ ArraySet类的具体用法?C++ ArraySet怎么用?C++ ArraySet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArraySet类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vOrderedVertices
vector<int> GraphTools::OrderVerticesByDegree(ArraySet const &inGraph, vector<SparseArraySet> const &neighborSets, bool const ascending)
{
vector<int> vOrderedVertices(inGraph.Size(), -1);
size_t maxDegree(0);
for (SparseArraySet const &neighborSet : neighborSets) {
maxDegree = max(maxDegree, neighborSet.Size());
}
vector<list<int>> vlVerticesByDegree(maxDegree + 1, list<int>());
for (size_t vertex = 0; vertex < neighborSets.size(); ++vertex) {
if (!inGraph.Contains(vertex)) continue;
//// std::cout << "maxDegree=" << maxDegree << ", degree=" << adjacencyList[vertex].size() << endl << flush;
vlVerticesByDegree[neighborSets[vertex].Size()].push_back(vertex);
}
if (ascending) {
size_t index(0);
for (size_t degree = 0; degree <= maxDegree; ++degree) {
for (int const vertex : vlVerticesByDegree[degree]) {
vOrderedVertices[index++] = vertex;
}
}
} else {
size_t index(0);
for (size_t degree = 0; degree <= maxDegree; ++degree) {
for (int const vertex : vlVerticesByDegree[maxDegree - degree]) {
vOrderedVertices[index++] = vertex;
}
}
}
return vOrderedVertices;
}
示例2: isReleaseSafeArrayReference
static bool isReleaseSafeArrayReference(SILValue Ref,
ArraySet &ReleaseSafeArrayReferences,
RCIdentityFunctionInfo *RCIA) {
auto RefRoot = RCIA->getRCIdentityRoot(Ref);
if (ReleaseSafeArrayReferences.count(RefRoot))
return true;
RefRoot = getArrayStructPointer(ArrayCallKind::kCheckIndex, RefRoot);
return ReleaseSafeArrayReferences.count(RefRoot);
}
示例3: 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;
}
示例4: TEST
TEST(CoordinateSetTest, StoreType)
{
ArraySet *array = new CoordinateSet<Vector3>;
EXPECT_TRUE(array->isType(Vector3()));
delete array;
array = 0;
array = new CoordinateSet<float>;
EXPECT_TRUE(array->isType(float()));
delete array;
array = 0;
}
示例5: componentCount
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);
}
}
}
示例6: currentSearch
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);
}
}
}
示例7: iterations
void IsolatesWithMatrix<NeighborSet>::RemoveAllIsolates(int const independentSetSize, vector<int> &vIsolateVertices, vector<int> &vOtherRemovedVertices, vector<pair<int,int>> &vAddedEdges, bool bConsiderAllVertices, ArraySet const &onlyConsider)
{
//// if (find (vIsolateVertices.begin(), vIsolateVertices.end(), 31) != vIsolateVertices.end())
//// cout << "Calling RemoveAllIsolates with 31 in the isolate set!" << endl;
#ifdef TIMERS
clock_t startClock = clock();
#endif // TIMERS
//// remaining = inGraph; // TODO/DS : We can optimize this by knowing which vertex (and neighbors where removed last.
//// if (vOtherRemovedVertices.empty()) {
// TODO/DS: Put this in; it saves us from having to consider obvious non-candidates. Only works if we establish
// the invariant that the graph contains no vertices that can be reduced.
//// if (bConsiderAllVertices) { ////true) { //bConsiderAllVertices) {
if (true) { //bConsiderAllVertices) {
remaining.Clear();
for (int const vertex : inGraph) {
remaining.Insert(vertex);
}
}
//// } else {
//// remaining.clear();
//// for (int const removedVertex : vOtherRemovedVertices) {
//// remaining.insert(neighbors[removedVertex].begin(), neighbors[removedVertex].end());
//// }
//// }
//// cout << "Removing all isolates." << endl << flush;
int iterations(0);
while (!remaining.Empty()) {
//// size_t const numRemoved(vIsolateVertices.size() + vOtherRemovedVertices.size());
//// if ((vIsolateVertices.size() + vOtherRemovedVertices.size()) %10000 == 0)
//// cout << "Progress: Removed: " << vIsolateVertices.size() << " isolates, and " << vOtherRemovedVertices.size() << " others" << endl << flush;
int const vertex = *(remaining.begin());
remaining.Remove(vertex);
if (!onlyConsider.Contains(vertex)) continue;
// can prune out high-degree vertices too. // but this is slow right now.
//// if (inGraph.size() - neighbors[vertex].size() < independentSetSize) {
//// remaining.insert(neighbors[vertex].begin(), neighbors[vertex].end());
//// RemoveVertex(vertex);
//// vOtherRemovedVertices.push_back(vertex);
//// continue;
//// }
//// cout << "Attempting to remove vertex " << vertex << endl << flush;
bool reduction = RemoveIsolatedClique(vertex, vIsolateVertices, vOtherRemovedVertices);
//// if (!reduction) {
//// reduction = RemoveIsolatedPath(vertex, vIsolateVertices, vOtherRemovedVertices, vAddedEdges);
//// }
//// if (find (vIsolateVertices.begin(), vIsolateVertices.end(), 31) != vIsolateVertices.end())
//// cout << "31 was added to the isolate set!" << endl;
//// if (!inGraph.Contains(31)) cout << "And it's not in the graph..." << endl << flush;
iterations++;
//// size_t const numNewRemoved(vIsolateVertices.size() + vOtherRemovedVertices.size());
//// if (numNewRemoved != numRemoved) {
//// cout << "Progress: Removed: " << vIsolateVertices.size() << " isolates, and " << vOtherRemovedVertices.size() << " others, in " << iterations << " iterations." << endl << flush;
//// iterations = 0;
//// cout << "Remaining graph has " << inGraph.Size() << " vertices." << endl << flush;
//// }
}
//// cout << "Removed " << isolates.size() - isolateSize << " isolates." << endl << flush;
//// cout << "Removed: " << vIsolateVertices.size() << " isolates, and " << vOtherRemovedVertices.size() << " others, in " << iterations << " iterations." << endl << flush;
#ifdef TIMERS
clock_t endClock = clock();
removeTimer += (endClock - startClock);
#endif // TIMERS
}
示例8: analyseInstruction
/// Analyse one instruction wrt. the instructions we have seen so far.
void analyseInstruction(SILInstruction *Inst) {
SILValue Array;
ArrayCallKind K;
auto BoundsEffect =
mayChangeArraySize(Inst, K, Array, ReleaseSafeArrayReferences, RCIA);
if (BoundsEffect == ArrayBoundsEffect::kMayChangeAny) {
DEBUG(llvm::dbgs() << " no safe because kMayChangeAny " << *Inst);
allArraysInMemoryAreUnsafe = true;
// No need to store specific arrays in this case.
UnsafeArrays.clear();
return;
}
assert(Array ||
K == ArrayCallKind::kNone &&
"Need to have an array for array semantic functions");
// We need to make sure that the array container is not aliased in ways
// that we don't understand.
if (Array && !isIdentifiedUnderlyingArrayObject(Array)) {
DEBUG(llvm::dbgs()
<< " not safe because of not identified underlying object "
<< *Array << " in " << *Inst);
allArraysInMemoryAreUnsafe = true;
// No need to store specific arrays in this case.
UnsafeArrays.clear();
return;
}
if (BoundsEffect == ArrayBoundsEffect::kMayChangeArg) {
UnsafeArrays.insert(Array);
return;
}
assert(BoundsEffect == ArrayBoundsEffect::kNone);
}
示例9: isUnsafe
/// Returns true if the Array is unsafe.
bool isUnsafe(SILValue Array) const {
return allArraysInMemoryAreUnsafe || UnsafeArrays.count(Array) != 0;
}