< prev index next >

src/hotspot/share/utilities/growableArray.hpp

Print this page

        

*** 24,33 **** --- 24,34 ---- #ifndef SHARE_UTILITIES_GROWABLEARRAY_HPP #define SHARE_UTILITIES_GROWABLEARRAY_HPP #include "memory/allocation.hpp" + #include "oops/array.hpp" #include "oops/oop.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/ostream.hpp"
*** 406,415 **** --- 407,422 ---- for (int i = 0; i < l->_len; i++) { raw_at_put_grow(_len, l->_data[i], E()); } } + void appendAll(const Array<E>* l) { + for (int i = 0; i < l->length(); i++) { + raw_at_put_grow(_len, l->at(i), E()); + } + } + void sort(int f(E*,E*)) { qsort(_data, length(), sizeof(E), (_sort_Fn)f); } // sort by fixed-stride sub arrays: void sort(int f(E*,E*), int stride) {
*** 575,597 **** const GrowableArray<E>* _array; // GrowableArray we iterate over int _position; // Current position in the GrowableArray UnaryPredicate _predicate; // Unary predicate the elements of the GrowableArray should satisfy public: ! GrowableArrayFilterIterator(const GrowableArrayIterator<E>& begin, UnaryPredicate filter_predicate) ! : _array(begin._array), _position(begin._position), _predicate(filter_predicate) { // Advance to first element satisfying the predicate ! while(_position != _array->length() && !_predicate(_array->at(_position))) { ++_position; } } GrowableArrayFilterIterator<E, UnaryPredicate>& operator++() { do { // Advance to next element satisfying the predicate ++_position; ! } while(_position != _array->length() && !_predicate(_array->at(_position))); return *this; } E operator*() { return _array->at(_position); } --- 582,604 ---- const GrowableArray<E>* _array; // GrowableArray we iterate over int _position; // Current position in the GrowableArray UnaryPredicate _predicate; // Unary predicate the elements of the GrowableArray should satisfy public: ! GrowableArrayFilterIterator(const GrowableArray<E>* array, UnaryPredicate filter_predicate) ! : _array(array), _position(0), _predicate(filter_predicate) { // Advance to first element satisfying the predicate ! while(!at_end() && !_predicate(_array->at(_position))) { ++_position; } } GrowableArrayFilterIterator<E, UnaryPredicate>& operator++() { do { // Advance to next element satisfying the predicate ++_position; ! } while(!at_end() && !_predicate(_array->at(_position))); return *this; } E operator*() { return _array->at(_position); }
*** 612,621 **** --- 619,632 ---- bool operator!=(const GrowableArrayFilterIterator<E, UnaryPredicate>& rhs) { assert(_array == rhs._array, "iterator belongs to different array"); return _position != rhs._position; } + + bool at_end() const { + return _array == NULL || _position == _array->end()._position; + } }; // Arrays for basic types typedef GrowableArray<int> intArray; typedef GrowableArray<int> intStack;
< prev index next >