merge more fast

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/nlphub@165145 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Erik Perrone 2018-03-15 16:21:09 +00:00
parent 24ff49d294
commit b2c98580da
1 changed files with 24 additions and 2 deletions

View File

@ -98,7 +98,7 @@ mergeAll = function(indices) {
}
}
}
/*
var end = false;
var counter = 1;
while(!end) {
@ -110,5 +110,27 @@ mergeAll = function(indices) {
if(counter == 100)
end = true;
}
return m.sort(compareSegments);
return m.sort(compareSegments);*/
m = m.sort(compareSegments);
var m2 = [];
var current = m[0];
for(var i=0; i<m.length; i++) {
var cfr = compareSegment(current, m[i]);
switch(cfr) {
case 0:
case -1:
current = mergeSegment(current, m[i])[0];
break;
default:
var s = mergeSegment(current, m[i]);
m2[m2.length] = s[0];
current = s[1];
break;
}
}
if((current[0] != m2[m2.length-1][0]) || (current[1] != m2[m2.length-1][1]))
m2[m2.length] = current;
return m2;
}