-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathCountArea.java
More file actions
64 lines (58 loc) · 1.47 KB
/
Copy pathCountArea.java
File metadata and controls
64 lines (58 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package segment;
import java.util.ArrayList;
public class CountArea
{
public ArrayList<Double> getArea(ArrayList<String> dataList)
{
String[] temp;
for(String obj:dataList)
{
temp = obj.split("/");
res.add(Double.parseDouble(temp[0]));
res.add(Double.parseDouble(temp[1]));
}
res = this.sortList(res);
return res;
}
//把数列从小到大排序
public ArrayList<Double> sortList(ArrayList<Double> doubleList)
{
int length = doubleList.size();
for(int index = 0;index<length;index++)
{
for(int j = 0;j<length - index - 1;j++)
{
if(doubleList.get(j) > doubleList.get(j + 1))
{
doubleList.add(j, doubleList.get(j + 1));
doubleList.remove(j+2);
}
}
}
return doubleList;
}
public double[][] transToArray(ArrayList<String> dataList)
{
int size = dataList.size();
double[][] data = new double[size][2];
String[] temp;
for(int i = 0;i < size;i++)
{
temp = dataList.get(i).split("/");
data[i][0] = Double.parseDouble(temp[0]);
data[i][1] = Double.parseDouble(temp[1]);
}
return data;
}
public ArrayList<String> getSegment(ArrayList<Double> doubleList)
{
ArrayList<String> arrayList = new ArrayList<String>();
int length = doubleList.size();
for(int i = 0;i < length-1;i++)
{
arrayList.add(doubleList.get(i)+"/"+doubleList.get(i+1));
}
return arrayList;
}
private static ArrayList<Double> res = new ArrayList<Double>();
}