< prev index next >

src/hotspot/share/gc/z/zArray.inline.hpp

Print this page

  1 /*
  2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */

 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 #ifndef SHARE_GC_Z_ZARRAY_INLINE_HPP
 25 #define SHARE_GC_Z_ZARRAY_INLINE_HPP
 26 
 27 #include "gc/z/zArray.hpp"
 28 #include "memory/allocation.inline.hpp"
 29 #include "runtime/atomic.hpp"
 30 
 31 template <typename T>
 32 inline ZArray<T>::ZArray() :
 33     _array(NULL),
 34     _size(0),
 35     _capacity(0) {}
 36 
 37 template <typename T>
 38 inline ZArray<T>::~ZArray() {
 39   if (_array != NULL) {
 40     FREE_C_HEAP_ARRAY(T, _array);
 41   }
 42 }
 43 
 44 template <typename T>
 45 inline size_t ZArray<T>::size() const {
 46   return _size;
 47 }
 48 
 49 template <typename T>
 50 inline bool ZArray<T>::is_empty() const {
 51   return size() == 0;
 52 }
 53 
 54 template <typename T>
 55 inline T ZArray<T>::at(size_t index) const {
 56   assert(index < _size, "Index out of bounds");
 57   return _array[index];
 58 }
 59 
 60 template <typename T>
 61 inline void ZArray<T>::expand(size_t new_capacity) {

  1 /*
  2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */

 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 #ifndef SHARE_GC_Z_ZARRAY_INLINE_HPP
 25 #define SHARE_GC_Z_ZARRAY_INLINE_HPP
 26 
 27 #include "gc/z/zArray.hpp"
 28 #include "memory/allocation.inline.hpp"
 29 #include "runtime/atomic.hpp"
 30 
 31 template <typename T>
 32 inline ZArray<T>::ZArray() :
 33     _array(NULL),
 34     _size(0),
 35     _capacity(0) {}
 36 
 37 template <typename T>
 38 inline ZArray<T>::~ZArray() {
 39   FREE_C_HEAP_ARRAY(T, _array);


 40 }
 41 
 42 template <typename T>
 43 inline size_t ZArray<T>::size() const {
 44   return _size;
 45 }
 46 
 47 template <typename T>
 48 inline bool ZArray<T>::is_empty() const {
 49   return size() == 0;
 50 }
 51 
 52 template <typename T>
 53 inline T ZArray<T>::at(size_t index) const {
 54   assert(index < _size, "Index out of bounds");
 55   return _array[index];
 56 }
 57 
 58 template <typename T>
 59 inline void ZArray<T>::expand(size_t new_capacity) {
< prev index next >