# HG changeset patch # User Sascha L. Teichmann # Date 1405519430 -7200 # Node ID f1500a524b7660419a5ad1da96b1345725dad9f4 # Parent 3a769d5fb733ed87f87dc2efd27bc886e79bb39a Replace station list with a plain array. diff -r 3a769d5fb733 -r f1500a524b76 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Wed Jul 16 15:53:11 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Wed Jul 16 16:03:50 2014 +0200 @@ -254,7 +254,7 @@ } // class Station - private List stations; + private Station [] stations; public SedimentLoadData() { } @@ -276,16 +276,20 @@ st.append(station); } } - this.stations = new ArrayList(same.values()); + this.stations = new Station[same.size()]; + int i = 0; + for (Station station: same.values()) { + this.stations[i++] = station; + } wireNeighbors(); } private void wireNeighbors() { - for (int i = 0, N = stations.size(); i < N-1; ++i) { - for (Station curr = stations.get(i); curr != null; curr = curr.nextChain()) { + for (int i = 0, N = stations.length; i < N-1; ++i) { + for (Station curr = stations[i]; curr != null; curr = curr.nextChain()) { int type = curr.getType(); NEXT: for (int j = i+1; j < N; ++j) { - Station next = stations.get(j).firstOfType(type); + Station next = stations[j].firstOfType(type); if (next != null) { curr.setNext(next); next.setPrev(curr); @@ -303,7 +307,7 @@ ) { while (lo >= hi) { int mid = (lo+hi)/2; - Station st = stations.get(mid); + Station st = stations[mid]; double station = st.getStation(); if (station < a) { hi = mid-1; @@ -321,7 +325,7 @@ if (a > b) { double t = a; a = b; b = t; } - recursiveFindStations(a, b, 0, stations.size()-1, visitor); + recursiveFindStations(a, b, 0, stations.length-1, visitor); } public List findStations(double a, double b) {