1
1
/*
2
- * Copyright (c) 1997, 2023 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1997, 2024 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -102,7 +102,6 @@ class GrowableArrayBase : public AnyObj {
102
102
};
103
103
104
104
template <typename E> class GrowableArrayIterator ;
105
- template <typename E, typename UnaryPredicate> class GrowableArrayFilterIterator ;
106
105
107
106
// Extends GrowableArrayBase with a typed data array.
108
107
//
@@ -841,7 +840,6 @@ class GrowableArrayCHeap : public GrowableArrayWithAllocator<E, GrowableArrayCHe
841
840
template <typename E>
842
841
class GrowableArrayIterator : public StackObj {
843
842
friend class GrowableArrayView <E>;
844
- template <typename F, typename UnaryPredicate> friend class GrowableArrayFilterIterator ;
845
843
846
844
private:
847
845
const GrowableArrayView<E>* _array; // GrowableArray we iterate over
@@ -868,56 +866,6 @@ class GrowableArrayIterator : public StackObj {
868
866
}
869
867
};
870
868
871
- // Custom STL-style iterator to iterate over elements of a GrowableArray that satisfy a given predicate
872
- template <typename E, class UnaryPredicate >
873
- class GrowableArrayFilterIterator : public StackObj {
874
- friend class GrowableArrayView <E>;
875
-
876
- private:
877
- const GrowableArrayView<E>* _array; // GrowableArray we iterate over
878
- int _position; // Current position in the GrowableArray
879
- UnaryPredicate _predicate; // Unary predicate the elements of the GrowableArray should satisfy
880
-
881
- public:
882
- GrowableArrayFilterIterator (const GrowableArrayIterator<E>& begin, UnaryPredicate filter_predicate) :
883
- _array (begin._array), _position(begin._position), _predicate(filter_predicate) {
884
- // Advance to first element satisfying the predicate
885
- while (_position != _array->length () && !_predicate (_array->at (_position))) {
886
- ++_position;
887
- }
888
- }
889
-
890
- GrowableArrayFilterIterator<E, UnaryPredicate>& operator ++() {
891
- do {
892
- // Advance to next element satisfying the predicate
893
- ++_position;
894
- } while (_position != _array->length () && !_predicate (_array->at (_position)));
895
- return *this ;
896
- }
897
-
898
- E operator *() { return _array->at (_position); }
899
-
900
- bool operator ==(const GrowableArrayIterator<E>& rhs) {
901
- assert (_array == rhs._array , " iterator belongs to different array" );
902
- return _position == rhs._position ;
903
- }
904
-
905
- bool operator !=(const GrowableArrayIterator<E>& rhs) {
906
- assert (_array == rhs._array , " iterator belongs to different array" );
907
- return _position != rhs._position ;
908
- }
909
-
910
- bool operator ==(const GrowableArrayFilterIterator<E, UnaryPredicate>& rhs) {
911
- assert (_array == rhs._array , " iterator belongs to different array" );
912
- return _position == rhs._position ;
913
- }
914
-
915
- bool operator !=(const GrowableArrayFilterIterator<E, UnaryPredicate>& rhs) {
916
- assert (_array == rhs._array , " iterator belongs to different array" );
917
- return _position != rhs._position ;
918
- }
919
- };
920
-
921
869
// Arrays for basic types
922
870
typedef GrowableArray<int > intArray;
923
871
typedef GrowableArray<int > intStack;
0 commit comments