8328862: Remove unused GrowableArrayFilterIterator
Reviewed-by: dholmes
This commit is contained in:
parent
9f920b9bbf
commit
acc4a82818
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2024, 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
|
||||
@ -102,7 +102,6 @@ public:
|
||||
};
|
||||
|
||||
template <typename E> class GrowableArrayIterator;
|
||||
template <typename E, typename UnaryPredicate> class GrowableArrayFilterIterator;
|
||||
|
||||
// Extends GrowableArrayBase with a typed data array.
|
||||
//
|
||||
@ -841,7 +840,6 @@ public:
|
||||
template <typename E>
|
||||
class GrowableArrayIterator : public StackObj {
|
||||
friend class GrowableArrayView<E>;
|
||||
template <typename F, typename UnaryPredicate> friend class GrowableArrayFilterIterator;
|
||||
|
||||
private:
|
||||
const GrowableArrayView<E>* _array; // GrowableArray we iterate over
|
||||
@ -868,56 +866,6 @@ class GrowableArrayIterator : public StackObj {
|
||||
}
|
||||
};
|
||||
|
||||
// Custom STL-style iterator to iterate over elements of a GrowableArray that satisfy a given predicate
|
||||
template <typename E, class UnaryPredicate>
|
||||
class GrowableArrayFilterIterator : public StackObj {
|
||||
friend class GrowableArrayView<E>;
|
||||
|
||||
private:
|
||||
const GrowableArrayView<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); }
|
||||
|
||||
bool operator==(const GrowableArrayIterator<E>& rhs) {
|
||||
assert(_array == rhs._array, "iterator belongs to different array");
|
||||
return _position == rhs._position;
|
||||
}
|
||||
|
||||
bool operator!=(const GrowableArrayIterator<E>& rhs) {
|
||||
assert(_array == rhs._array, "iterator belongs to different array");
|
||||
return _position != rhs._position;
|
||||
}
|
||||
|
||||
bool operator==(const GrowableArrayFilterIterator<E, UnaryPredicate>& rhs) {
|
||||
assert(_array == rhs._array, "iterator belongs to different array");
|
||||
return _position == rhs._position;
|
||||
}
|
||||
|
||||
bool operator!=(const GrowableArrayFilterIterator<E, UnaryPredicate>& rhs) {
|
||||
assert(_array == rhs._array, "iterator belongs to different array");
|
||||
return _position != rhs._position;
|
||||
}
|
||||
};
|
||||
|
||||
// Arrays for basic types
|
||||
typedef GrowableArray<int> intArray;
|
||||
typedef GrowableArray<int> intStack;
|
||||
|
Loading…
Reference in New Issue
Block a user