--- a/hotspot/src/share/vm/utilities/growableArray.hpp Fri Mar 09 13:34:45 2012 -0800
+++ b/hotspot/src/share/vm/utilities/growableArray.hpp Mon Mar 12 10:46:47 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -198,8 +198,11 @@
return idx;
}
- void append_if_missing(const E& elem) {
- if (!contains(elem)) append(elem);
+ bool append_if_missing(const E& elem) {
+ // Returns TRUE if elem is added.
+ bool missed = !contains(elem);
+ if (missed) append(elem);
+ return missed;
}
E at(int i) const {
@@ -292,12 +295,22 @@
ShouldNotReachHere();
}
+ // The order is preserved.
void remove_at(int index) {
assert(0 <= index && index < _len, "illegal index");
for (int j = index + 1; j < _len; j++) _data[j-1] = _data[j];
_len--;
}
+ // The order is changed.
+ void delete_at(int index) {
+ assert(0 <= index && index < _len, "illegal index");
+ if (index < --_len) {
+ // Replace removed element with last one.
+ _data[index] = _data[_len];
+ }
+ }
+
// inserts the given element before the element at index i
void insert_before(const int idx, const E& elem) {
check_nesting();