MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / folderIsSelfOrDescendant

Function folderIsSelfOrDescendant

app/src/DataModel/ProjectModel.cpp:81–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 */
80template<typename Folder>
81static bool folderIsSelfOrDescendant(const std::vector<Folder>& folders,
82 int folderId,
83 int candidate)
84{
85 const int kMax = static_cast<int>(folders.size());
86 int p = candidate;
87 for (int i = 0; i <= kMax && p != -1; ++i) {
88 if (p == folderId)
89 return true;
90
91 int parent = -1;
92 for (const auto& f : folders)
93 if (f.folderId == p) {
94 parent = f.parentFolderId;
95 break;
96 }
97
98 p = parent;
99 }
100
101 return false;
102}
103
104/**
105 * @brief Detaches cyclic or dangling folder parents and resets entities pointing at a missing

Callers 4

moveFolderToFolderMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected