src/share/vm/utilities/growableArray.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/utilities

src/share/vm/utilities/growableArray.hpp

Print this page




 486     for (int i = 0; i < _len; i++) tty->print(INTPTR_FORMAT " ", *(intptr_t*)&(_data[i]));
 487     tty->print("}\n");
 488 }
 489 
 490 // Custom STL-style iterator to iterate over GrowableArrays
 491 // It is constructed by invoking GrowableArray::begin() and GrowableArray::end()
 492 template<class E> class GrowableArrayIterator : public StackObj {
 493   friend class GrowableArray<E>;
 494   template<class F, class UnaryPredicate> friend class GrowableArrayFilterIterator;
 495 
 496  private:
 497   const GrowableArray<E>* _array; // GrowableArray we iterate over
 498   int _position;                  // The current position in the GrowableArray
 499 
 500   // Private constructor used in GrowableArray::begin() and GrowableArray::end()
 501   GrowableArrayIterator(const GrowableArray<E>* array, int position) : _array(array), _position(position) {
 502     assert(0 <= position && position <= _array->length(), "illegal position");
 503   }
 504 
 505  public:

 506   GrowableArrayIterator<E>& operator++()  { ++_position; return *this; }
 507   E operator*()                           { return _array->at(_position); }
 508 
 509   bool operator==(const GrowableArrayIterator<E>& rhs)  {
 510     assert(_array == rhs._array, "iterator belongs to different array");
 511     return _position == rhs._position;
 512   }
 513 
 514   bool operator!=(const GrowableArrayIterator<E>& rhs)  {
 515     assert(_array == rhs._array, "iterator belongs to different array");
 516     return _position != rhs._position;
 517   }
 518 };
 519 
 520 // Custom STL-style iterator to iterate over elements of a GrowableArray that satisfy a given predicate
 521 template<class E, class UnaryPredicate> class GrowableArrayFilterIterator : public StackObj {
 522   friend class GrowableArray<E>;
 523 
 524  private:
 525   const GrowableArray<E>* _array;   // GrowableArray we iterate over




 486     for (int i = 0; i < _len; i++) tty->print(INTPTR_FORMAT " ", *(intptr_t*)&(_data[i]));
 487     tty->print("}\n");
 488 }
 489 
 490 // Custom STL-style iterator to iterate over GrowableArrays
 491 // It is constructed by invoking GrowableArray::begin() and GrowableArray::end()
 492 template<class E> class GrowableArrayIterator : public StackObj {
 493   friend class GrowableArray<E>;
 494   template<class F, class UnaryPredicate> friend class GrowableArrayFilterIterator;
 495 
 496  private:
 497   const GrowableArray<E>* _array; // GrowableArray we iterate over
 498   int _position;                  // The current position in the GrowableArray
 499 
 500   // Private constructor used in GrowableArray::begin() and GrowableArray::end()
 501   GrowableArrayIterator(const GrowableArray<E>* array, int position) : _array(array), _position(position) {
 502     assert(0 <= position && position <= _array->length(), "illegal position");
 503   }
 504 
 505  public:
 506   GrowableArrayIterator() : _array(NULL), _position(0) { }
 507   GrowableArrayIterator<E>& operator++()  { ++_position; return *this; }
 508   E operator*()                           { return _array->at(_position); }
 509 
 510   bool operator==(const GrowableArrayIterator<E>& rhs)  {
 511     assert(_array == rhs._array, "iterator belongs to different array");
 512     return _position == rhs._position;
 513   }
 514 
 515   bool operator!=(const GrowableArrayIterator<E>& rhs)  {
 516     assert(_array == rhs._array, "iterator belongs to different array");
 517     return _position != rhs._position;
 518   }
 519 };
 520 
 521 // Custom STL-style iterator to iterate over elements of a GrowableArray that satisfy a given predicate
 522 template<class E, class UnaryPredicate> class GrowableArrayFilterIterator : public StackObj {
 523   friend class GrowableArray<E>;
 524 
 525  private:
 526   const GrowableArray<E>* _array;   // GrowableArray we iterate over


src/share/vm/utilities/growableArray.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File