< prev index next >

src/hotspot/share/utilities/growableArray.hpp

Print this page

303     found = false;
304     int min = 0;
305     int max = length() - 1;
306 
307     while (max >= min) {
308       int mid = (int)(((uint)max + min) / 2);
309       E value = at(mid);
310       int diff = cc->do_compare(key, value);
311       if (diff > 0) {
312         min = mid + 1;
313       } else if (diff < 0) {
314         max = mid - 1;
315       } else {
316         found = true;
317         return mid;
318       }
319     }
320     return min;
321   }
322 











323   size_t data_size_in_bytes() const {
324     return _len * sizeof(E);
325   }
326 
327   void print() const {
328     tty->print("Growable Array " INTPTR_FORMAT, p2i(this));
329     tty->print(": length %d (_max %d) { ", _len, _max);
330     for (int i = 0; i < _len; i++) {
331       tty->print(INTPTR_FORMAT " ", *(intptr_t*)&(_data[i]));
332     }
333     tty->print("}\n");
334   }
335 };
336 
337 template<typename E>
338 const GrowableArrayView<E> GrowableArrayView<E>::EMPTY(nullptr, 0, 0);
339 
340 // GrowableArrayWithAllocator extends the "view" with
341 // the capability to grow and deallocate the data array.
342 //

303     found = false;
304     int min = 0;
305     int max = length() - 1;
306 
307     while (max >= min) {
308       int mid = (int)(((uint)max + min) / 2);
309       E value = at(mid);
310       int diff = cc->do_compare(key, value);
311       if (diff > 0) {
312         min = mid + 1;
313       } else if (diff < 0) {
314         max = mid - 1;
315       } else {
316         found = true;
317         return mid;
318       }
319     }
320     return min;
321   }
322 
323   void truncate_to(int idx) {
324     for (int i = 0, j = idx; j < length(); i++, j++) {
325       at_put(i, at(j));
326     }
327     trunc_to(length() - idx);
328   }
329 
330   void truncate_from(int idx) {
331     trunc_to(idx);
332   }
333 
334   size_t data_size_in_bytes() const {
335     return _len * sizeof(E);
336   }
337 
338   void print() const {
339     tty->print("Growable Array " INTPTR_FORMAT, p2i(this));
340     tty->print(": length %d (_max %d) { ", _len, _max);
341     for (int i = 0; i < _len; i++) {
342       tty->print(INTPTR_FORMAT " ", *(intptr_t*)&(_data[i]));
343     }
344     tty->print("}\n");
345   }
346 };
347 
348 template<typename E>
349 const GrowableArrayView<E> GrowableArrayView<E>::EMPTY(nullptr, 0, 0);
350 
351 // GrowableArrayWithAllocator extends the "view" with
352 // the capability to grow and deallocate the data array.
353 //
< prev index next >