#include"ses_core.h"
-int _ses_path_cmp(const void* v0, const void* v1);
-
static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
{
if (!path)
if (path->childs) {
- scf_vector_qsort(path->childs, _ses_path_cmp);
-
for (i = path->childs->size - 1; i >= 0; i--) {
child = path->childs->data[i];
#include"ses_core.h"
-int _ses_path_cmp(const void* v0, const void* v1)
+static int _ses_path_cmp(const void* v0, const void* v1)
{
const ses_path_t* p0 = *(const ses_path_t**)v0;
const ses_path_t* p1 = *(const ses_path_t**)v1;
return ret;
}
+static int _ses_child_cmp(const void* v0, const void* v1)
+{
+ const ses_path_t* p0 = *(const ses_path_t**)v0;
+ const ses_path_t* p1 = *(const ses_path_t**)v1;
+
+ if (p0->parent_p0 <= p1->parent_p0 && p0->parent_p1 >= p1->parent_p1)
+ return -1;
+
+ if (p0->parent_p0 >= p1->parent_p0 && p0->parent_p1 <= p1->parent_p1)
+ return 1;
+ return 0;
+}
+
+static void _topo_path_sort(ses_path_t* path)
+{
+ if (!path || !path->childs || path->childs->size <= 0)
+ return;
+
+ ses_path_t* child;
+ int i;
+
+ for (i = 0; i < path->childs->size; i++) {
+ child = path->childs->data[i];
+
+ _topo_path_sort(child);
+ }
+
+ scf_vector_qsort(path->childs, _ses_child_cmp);
+}
+
static int _topo_layers(scf_vector_t* paths)
{
ses_path_t* child;
}
}
+ for (i = 0; i < paths->size; i++) {
+ child = paths->data[i];
+
+ _topo_path_sort(child);
+ }
+
return 0;
}