Mercurial > hg > truffle
diff src/share/vm/utilities/growableArray.hpp @ 6152:958bb4b7be49
Merge
author | asaha |
---|---|
date | Tue, 10 Apr 2012 10:42:34 -0700 |
parents | ee138854b3a6 |
children | d2a62e0f25eb |
line wrap: on
line diff
--- a/src/share/vm/utilities/growableArray.hpp Wed Apr 04 20:44:38 2012 -0700 +++ b/src/share/vm/utilities/growableArray.hpp Tue Apr 10 10:42:34 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();