arraySegment.js Use arrary struct to deliver the Segment class
result:
[]
[[10,1],[30,0]]
[[10,1],[20,2],[30,1],[40,0]]
[[10,-1],[20,0],[30,-1],[40,0]]
Test case one run time is: 2.6228904724121094 ms.
[]
[[10,1],[30,0]]
[[10,1],[20,2],[30,1],[40,0]]
[[20,1],[30,0]]
[[10,-1],[20,0],[30,-1],[40,0]]
Test case two run time is: 0.196746826171875 ms.
*** Case 9: Performence Test ***
1000 ops time: 13.56 ms
[[0,1],[2,2],[3,-3],[4,-2],[6,0],[7,6],[8,3],[9,7],[11,8],[14,12],[23,14],[24,10],[27,2],[64,-3],[69,1],[72,4],[82,5],[91,1],[98,0],[107,7],[142,3],[149,4],[159,1],[168,-2],[172,4],[217,-3],[223,-4],[224,0],[239,2],[241,-6],[287,-5],[313,3],[316,-3],[364,1],[403,-1],[406,3],[407,7],[411,4],[437,-5],[444,1],[483,-3],[519,1],[525,0],[535,-4],[558,4],[561,-4],[634,2],[639,-4],[642,-1],[706,-5],[715,0],[763,-5],[775,-8],[790,1],[813,-6],[822,-8],[846,-9],[853,0],[857,3],[877,-4],[878,-3],[881,-4],[883,-2],[886,-4],[899,-1],[909,3],[932,5],[940,1],[962,2],[971,-2],[986,2],[1007,-7],[1014,-5],[1016,-9],[1033,-11],[1046,-10],[1061,-6],[1062,-1],[1076,4],[1090,0]]
AVLSegment.js Use Tree struct to deliver the Segment class
result:
[]
[[10,1],[30,0]]
[[10,1],[20,2],[30,1],[40,0]]
[[10,-1],[20,0],[30,-1],[40,0]]
Test case one run time is: 2.5823278427124023 ms.
[]
[[10,1],[30,0]]
[[10,1],[20,2],[30,1],[40,0]]
[[20,1],[30,0]]
[[10,-1],[20,0],[30,-1],[40,0]]
Test case two run time is: 0.3250274658203125 ms.
*** Case 1: Add Function ***
[[0,5],[10,0]]
[[0,5],[5,8],[10,3],[15,0]]
*** Case 2: Set Function ***
[[0,2],[20,0]]
[[0,2],[5,7],[15,2],[20,0]]
*** Case 3: Regions Covered ***
[[0,1],[5,2],[7,3],[10,2],[12,1],[15,0]]
*** Case 4: Negative Value ***
[[0,5],[10,0]]
[[0,5],[3,2],[8,5],[10,0]]
*** Case 5: Edge Merge ***
[[0,2],[20,0]]
*** Case 6: [Error Input] Single Point ***
[]
[]
[]
*** Case 7: Merge Case ***
[[0,1],[30,0]]
*** Case 8: Big Value ***
[[1000,100],[1500,150],[2000,50],[2500,0]]
*** Case 9: Performence Test ***
10000 ops time: 70.26 ms
[[0,-4],[1,-8],[4,-7],[5,-8],[8,-6],[10,-5],[15,-6],[17,-9],[49,-7],[52,-9],[62,-5],[66,4],[104,3],[108,-2],[118,-3],[124,-1],[133,4],[140,3],[147,-4],[150,2],[152,-4],[182,4],[194,-4],[217,4],[224,-1],[246,9],[248,1],[269,-2],[335,-6],[342,1],[373,-2],[419,1],[429,2],[437,5],[449,2],[457,-4],[495,-2],[500,4],[520,0],[525,-5],[544,-4],[561,-5],[565,-3],[574,1],[578,0],[579,-1],[625,1],[633,0],[648,-2],[666,1],[673,-5],[682,-9],[700,-5],[714,-1],[722,-3],[725,-5],[740,-13],[741,-9],[742,-6],[748,-9],[754,-8],[756,-5],[762,-3],[764,-5],[767,-3],[768,-1],[786,3],[787,-3],[796,0],[812,-4],[834,-1],[862,-4],[867,-9],[892,-14],[904,-19],[923,-14],[926,-9],[927,-1],[936,-5],[937,-4],[951,-8],[982,-3],[986,-2],[1072,-3],[1075,1],[1077,2],[1082,3],[1092,4],[1095,1],[1096,0]]
*** Case 10: Empty Result ***
[[0,5],[10,0]]
[]
*** Case 11: Nested Range ***
[[0,1],[10,3],[15,6],[20,4],[25,1],[100,0]]
intensitySegment.test.js