16
16
*/
17
17
package uk .me .parabola .splitter ;
18
18
19
- import java .util .Iterator ;
20
19
import java .util .LinkedList ;
21
20
import java .util .ListIterator ;
22
21
@@ -32,10 +31,10 @@ public class AreaSplitter {
32
31
/**
33
32
* Split a single area which would normally be the complete area of the map.
34
33
* We just split areas that are too big into two. We make a rough determination
35
- * of the largest dimention and split that way.
34
+ * of the largest dimension and split that way.
36
35
*
37
36
* @param area The original area.
38
- * @param max The maximimum number of nodes that any area can contain.
37
+ * @param max The maximum number of nodes that any area can contain.
39
38
* @return An array of areas. Each will have less than the specified number of nodes.
40
39
*/
41
40
public AreaList split (SubArea area , int max ) {
@@ -50,12 +49,12 @@ public AreaList split(SubArea area, int max) {
50
49
ListIterator <SubArea > it = l .listIterator ();
51
50
while (it .hasNext ()) {
52
51
SubArea workarea = it .next ();
53
- SplitIntMap map = workarea .getCoords ();
54
- if (map == null ) {
52
+ SplitIntList list = workarea .getCoords ();
53
+ if (list == null ) {
55
54
continue ;
56
55
}
57
56
58
- int size = map .size ();
57
+ int size = list .size ();
59
58
System .out .println ("comparing size " + workarea .getSize ());
60
59
if (size < max ) {
61
60
workarea .clear ();
@@ -95,14 +94,14 @@ private SubArea[] splitHoriz(SubArea base) {
95
94
System .out .println ("left = " + left );
96
95
System .out .println ("right = " + right );
97
96
98
- SplitIntMap baseCoords = base .getCoords ();
97
+ SplitIntList baseCoords = base .getCoords ();
99
98
100
- Iterator < IntIntMap . Entry > it = baseCoords .fastIterator ();
99
+ SplitIntList . Iterator it = baseCoords .getIterator ();
101
100
int count = 0 ;
102
101
long total = 0 ;
103
102
while (it .hasNext ()) {
104
- IntIntMap . Entry entry = it .next ();
105
- int lon = extractLongitude (entry . getValue () );
103
+ int val = it .next ();
104
+ int lon = extractLongitude (val );
106
105
assert lon >= left && lon <= right : lon ;
107
106
count ++;
108
107
total += lon - left + 1 ;
@@ -120,15 +119,13 @@ private SubArea[] splitHoriz(SubArea base) {
120
119
SubArea a1 = new SubArea (b1 );
121
120
SubArea a2 = new SubArea (b2 );
122
121
123
- it = baseCoords .fastDeletingIterator ();
122
+ it = baseCoords .getDeletingIterator ();
124
123
while (it .hasNext ()) {
125
- IntIntMap .Entry entry = it .next ();
126
- int key = entry .getKey ();
127
- int co = entry .getValue ();
124
+ int co = it .next ();
128
125
if (extractLongitude (co ) < mid ) {
129
- a1 .put ( key , co );
126
+ a1 .add ( co );
130
127
} else {
131
- a2 .put ( key , co );
128
+ a2 .add ( co );
132
129
}
133
130
}
134
131
@@ -142,15 +139,15 @@ private SubArea[] splitVert(SubArea base) {
142
139
int top = bounds .getMaxLat ();
143
140
int bot = bounds .getMinLat ();
144
141
145
- SplitIntMap caseCoords = base .getCoords ();
142
+ SplitIntList caseCoords = base .getCoords ();
146
143
147
- Iterator < IntIntMap . Entry > it = caseCoords .fastIterator ();
144
+ SplitIntList . Iterator it = caseCoords .getIterator ();
148
145
int count = 0 ;
149
146
long total = 0 ;
150
147
while (it .hasNext ()) {
151
- IntIntMap . Entry entry = it .next ();
152
- int lat = extractLatitude (entry . getValue () );
153
- assert lat >= bot && extractLongitude (entry . getValue () ) <= top : lat ;
148
+ int val = it .next ();
149
+ int lat = extractLatitude (val );
150
+ assert lat >= bot && extractLongitude (val ) <= top : lat ;
154
151
count ++;
155
152
total += lat - bot ;
156
153
}
@@ -167,15 +164,13 @@ private SubArea[] splitVert(SubArea base) {
167
164
168
165
caseCoords = base .getCoords ();
169
166
170
- it = caseCoords .fastDeletingIterator ();
167
+ it = caseCoords .getDeletingIterator ();
171
168
while (it .hasNext ()) {
172
- IntIntMap .Entry entry = it .next ();
173
- int key = entry .getKey ();
174
- int co = entry .getValue ();
169
+ int co = it .next ();
175
170
if (extractLatitude (co ) <= mid ) {
176
- a1 .put ( key , co );
171
+ a1 .add ( co );
177
172
} else {
178
- a2 .put ( key , co );
173
+ a2 .add ( co );
179
174
}
180
175
}
181
176
0 commit comments