changeset 8040:f1500a524b76

Replace station list with a plain array.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 16 Jul 2014 16:03:50 +0200
parents 3a769d5fb733
children 01ad09af0975
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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<Station> stations;
+    private Station [] stations;
 
     public SedimentLoadData() {
     }
@@ -276,16 +276,20 @@
                 st.append(station);
             }
         }
-        this.stations = new ArrayList<Station>(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<Station> findStations(double a, double b) {

http://dive4elements.wald.intevation.org