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

src/share/vm/utilities/growableArray.hpp

Print this page




 181   ~GrowableArray()              { if (on_C_heap()) clear_and_deallocate(); }
 182 
 183   void  clear()                 { _len = 0; }
 184   int   length() const          { return _len; }
 185   void  trunc_to(int l)         { assert(l <= _len,"cannot increase length"); _len = l; }
 186   bool  is_empty() const        { return _len == 0; }
 187   bool  is_nonempty() const     { return _len != 0; }
 188   bool  is_full() const         { return _len == _max; }
 189   DEBUG_ONLY(E* data_addr() const      { return _data; })
 190 
 191   void print();
 192 
 193   int append(const E& elem) {
 194     check_nesting();
 195     if (_len == _max) grow(_len);
 196     int idx = _len++;
 197     _data[idx] = elem;
 198     return idx;
 199   }
 200 
 201   void append_if_missing(const E& elem) {
 202     if (!contains(elem)) append(elem);



 203   }
 204 
 205   E at(int i) const {
 206     assert(0 <= i && i < _len, "illegal index");
 207     return _data[i];
 208   }
 209 
 210   E* adr_at(int i) const {
 211     assert(0 <= i && i < _len, "illegal index");
 212     return &_data[i];
 213   }
 214 
 215   E first() const {
 216     assert(_len > 0, "empty list");
 217     return _data[0];
 218   }
 219 
 220   E top() const {
 221     assert(_len > 0, "empty list");
 222     return _data[_len-1];




 181   ~GrowableArray()              { if (on_C_heap()) clear_and_deallocate(); }
 182 
 183   void  clear()                 { _len = 0; }
 184   int   length() const          { return _len; }
 185   void  trunc_to(int l)         { assert(l <= _len,"cannot increase length"); _len = l; }
 186   bool  is_empty() const        { return _len == 0; }
 187   bool  is_nonempty() const     { return _len != 0; }
 188   bool  is_full() const         { return _len == _max; }
 189   DEBUG_ONLY(E* data_addr() const      { return _data; })
 190 
 191   void print();
 192 
 193   int append(const E& elem) {
 194     check_nesting();
 195     if (_len == _max) grow(_len);
 196     int idx = _len++;
 197     _data[idx] = elem;
 198     return idx;
 199   }
 200 
 201   bool append_if_missing(const E& elem) {
 202     // Returns TRUE if elem is added.
 203     bool missed = !contains(elem);
 204     if (missed) append(elem);
 205     return missed;
 206   }
 207 
 208   E at(int i) const {
 209     assert(0 <= i && i < _len, "illegal index");
 210     return _data[i];
 211   }
 212 
 213   E* adr_at(int i) const {
 214     assert(0 <= i && i < _len, "illegal index");
 215     return &_data[i];
 216   }
 217 
 218   E first() const {
 219     assert(_len > 0, "empty list");
 220     return _data[0];
 221   }
 222 
 223   E top() const {
 224     assert(_len > 0, "empty list");
 225     return _data[_len-1];


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