Created
March 7, 2017 23:49
-
-
Save LieutenantChips/e302ceb9da0c04f628122bb885a1c042 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ArrayList<LatLng> closestPoints_stupidSort(ArrayList<Pair<LatLng, Double>> pairs) { | |
ArrayList<Pair<LatLng, Double>> newPairs = new ArrayList<Pair<LatLng,Double>>(); | |
for(int i = 0; i < pairs.size(); i ++){ | |
if(newPairs.size() == 0){ newPairs.add(new Pair<LatLng, Double>(pairs.get(i).first, pairs.get(i).second)); continue; } | |
for(int j = 0; j < newPairs.size(); j++){ | |
if(newPairs.get(j).second > pairs.get(i).second){ | |
int jf = (j > 0)? j-1: j; | |
Log.v("NEW VAL OF JF : ", newPairs.size() + " : " + jf); | |
newPairs.add(jf, new Pair<LatLng, Double>(pairs.get(i).first, pairs.get(i).second)); | |
continue; | |
} | |
} | |
//else | |
newPairs.add(pairs.get(i)); | |
} | |
ArrayList<LatLng> finalList = new ArrayList<LatLng>(); | |
for(int i =0; i < newPairs.size(); i ++){ | |
finalList.add(newPairs.get(i).first); | |
} | |
return finalList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment