MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / topological_sort_visit

Function topological_sort_visit

StereoKitC/systems/system.cpp:280–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278#define MARK_TEMP 1
279#define MARK_PERM 2
280int32_t topological_sort_visit(sort_dependency_t *dependencies, int32_t count, int32_t index, uint8_t *marks, int32_t *sorted_curr, int32_t *out_order) {
281 if (marks[index] == MARK_PERM) return 0;
282 if (marks[index] == MARK_TEMP) return index;
283 marks[index] = MARK_TEMP;
284 for (int32_t i = 0; i < count; i++) {
285 for (int32_t d = 0; d < dependencies[i].count; d++) {
286 if (dependencies[i].ids[d] == index) {
287 int result = topological_sort_visit(dependencies, count, i, marks, sorted_curr, out_order);
288 if (result != 0)
289 return result;
290 }
291 }
292 }
293 marks[index] = MARK_PERM;
294 out_order[*sorted_curr] = index;
295 *sorted_curr = *sorted_curr-1;
296 return 0;
297}
298
299
300} // namespace sk

Callers 1

topological_sortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected