diff src/share/vm/utilities/growableArray.hpp @ 22549:f39ccee58e7a

cleanup GrowableArray sorted find and insert
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 10 Sep 2015 16:25:32 -0700
parents 7848fc12602b
children
line wrap: on
line diff
--- a/src/share/vm/utilities/growableArray.hpp	Wed Sep 09 17:56:30 2015 -0700
+++ b/src/share/vm/utilities/growableArray.hpp	Thu Sep 10 16:25:32 2015 -0700
@@ -377,17 +377,17 @@
   // matching key according to the static compare function.  Insert
   // that element is not already in the list.  Assumes the list is
   // already sorted according to compare function.
-  template <int compare(E, E)> E find_insert_binary(E key) {
+  template <int compare(E&, E&)> E insert_sorted(E& key) {
     bool found;
-    int location = find_binary<E, compare>(key, found);
+    int location = find_sorted<E, compare>(key, found);
     if (!found) {
       assert(location <= length(), "out of range");
-      insert_binary(location, key);
+      insert_before(location, key);
     }
     return at(location);
   }
 
-  template <typename K, int compare(K, E)> int find_binary(K key, bool& found) {
+  template <typename K, int compare(K&, E&)> int find_sorted(K& key, bool& found) {
     found = false;
     int min = 0;
     int max = length() - 1;
@@ -407,21 +407,6 @@
     }
     return min;
   }
-
-  // Insert a new element at location, moving values as needed.
-  void insert_binary(int location, E element) {
-    int len = length();
-    if (len == location) {
-      append(element);
-    } else {
-      append(at(len-1));
-      int pos;
-      for (pos = len-2; pos >= location; pos--) {
-        at_put(pos+1, at(pos));
-      }
-      at_put(location, element);
-    }
-  }
 };
 
 // Global GrowableArray methods (one instance in the library per each 'E' type).