Revision 11473
trunk/libraries/libIverUtiles/src/com/iver/utiles/search/BinarySearchUsingFirstCharacters.java | ||
---|---|---|
240 | 240 |
obj = list2.get(i); |
241 | 241 |
|
242 | 242 |
// Don't add items which are already in the list |
243 |
if (!list.contains(obj)) { |
|
243 |
if (!list.contains(obj)) {
|
|
244 | 244 |
// Adds in sort order the new item: |
245 | 245 |
for (j = 0; j < list.size(); j ++) { |
246 | 246 |
if (list.get(j).toString().compareTo(obj.toString()) > 0) |
... | ... | |
248 | 248 |
} |
249 | 249 |
|
250 | 250 |
list.add(j, obj); |
251 |
System.out.println("A?ade: " + obj); |
|
252 | 251 |
} |
253 | 252 |
} |
254 | 253 |
|
254 |
// It's possible that some elements at the end wouldn't be found -> another small search |
|
255 |
size = list.size(); |
|
256 |
if (size == 0) { |
|
257 |
j = 0; |
|
258 |
} |
|
259 |
else { |
|
260 |
j = sortOrderedItems.indexOf(list.get(size - 1)); |
|
261 |
} |
|
262 |
|
|
263 |
j++; |
|
264 |
|
|
265 |
if (j < sortOrderedItems.size()) { |
|
266 |
do { |
|
267 |
obj = sortOrderedItems.get( j ); |
|
268 |
|
|
269 |
if (obj.toString().toLowerCase().startsWith( text.toLowerCase())) { |
|
270 |
list.add(size, obj); |
|
271 |
} |
|
272 |
|
|
273 |
j++; |
|
274 |
} |
|
275 |
while (j < sortOrderedItems.size()); |
|
276 |
} |
|
277 |
|
|
255 | 278 |
return list; |
256 | 279 |
} |
257 | 280 |
} |
Also available in: Unified diff