Results 1 to 2 of 2
- 11-30-2008, 08:50 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 10
- Rep Power
- 0
help with concurrent modification exception
I am sort of new to java, and I want to do things in a semi-functionaly way, just for fun. So I wrote a small library of static methods for listoperations, a functional style insertion sort, and then I got stuck on merge sort. I have written merge sort before in java, but I wanted to do it in a functional way. In the code I am going to paste below, I am almost certain that merge is working correctly. I have tested it up and down, with manually created lists. I am also certain that halve works correctly. All methods are static. The code I have for mergeSort is:
And I get concurrent modification exception. I am not using threads.Java Code:public static <t extends Comparable<t>> List<t> mergeSort(List<t> list){ //System.out.println("hhh"); //if (list.isEmpty()){ // List<t> empty = new LinkedList<t>(); // return empty; //} if(list.size() <= 1){//was else if // System.out.println("aahhhh"); return list; } else{ //System.out.println("mmm"); Pair<List<t>> pair = ListOps.halve(list); List<t> firstH = mergeSort(pair.fst()); List<t> lastH = mergeSort(pair.snd()); return merge2(firstH,lastH); } }
- 11-30-2008, 09:19 PM #2
Member
- Join Date
- Oct 2008
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
How to change the date of modification of a file
By Java Tip in forum java.ioReplies: 0Last Post: 04-05-2008, 10:10 AM -
Inventory Program modification help
By badness in forum Java AppletsReplies: 1Last Post: 01-17-2008, 05:24 AM -
Concurrent Applications
By m@tqi in forum Advanced JavaReplies: 1Last Post: 12-01-2007, 12:09 AM -
Getting modification and expiration date of content
By Java Tip in forum Java TipReplies: 0Last Post: 11-26-2007, 01:20 PM -
Concurrent Versions System (CVS)
By JavaForums in forum EclipseReplies: 0Last Post: 05-02-2007, 03:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks