< prev index next >

src/hotspot/share/gc/z/zList.hpp

Print this page
rev 57095 : [mq]: use
rev 57096 : [mq]: trailing_semi


   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  */
  23 
  24 #ifndef SHARE_GC_Z_ZLIST_HPP
  25 #define SHARE_GC_Z_ZLIST_HPP
  26 
  27 #include "memory/allocation.hpp"

  28 
  29 template <typename T> class ZList;
  30 
  31 // Element in a doubly linked list
  32 template <typename T>
  33 class ZListNode {
  34   friend class ZList<T>;
  35 
  36 private:
  37   ZListNode* _next;
  38   ZListNode* _prev;
  39 
  40   ZListNode(ZListNode* next, ZListNode* prev);
  41 
  42   void set_unused();
  43 
  44 public:
  45   ZListNode();
  46   ~ZListNode();
  47 
  48   bool is_unused() const;
  49 };
  50 
  51 // Doubly linked list
  52 template <typename T>
  53 class ZList {
  54 private:
  55   ZListNode<T> _head;
  56   size_t       _size;
  57 
  58   // Passing by value and assignment is not allowed
  59   ZList(const ZList<T>& list);
  60   ZList<T>& operator=(const ZList<T>& list);
  61 
  62   void verify() const;
  63 
  64   void insert(ZListNode<T>* before, ZListNode<T>* node);
  65 
  66   ZListNode<T>* cast_to_inner(T* elem) const;
  67   T* cast_to_outer(ZListNode<T>* node) const;
  68 
  69 public:
  70   ZList();
  71 
  72   size_t size() const;
  73   bool is_empty() const;
  74 
  75   T* first() const;
  76   T* last() const;
  77   T* next(T* elem) const;
  78   T* prev(T* elem) const;
  79 
  80   void insert_first(T* elem);




   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  */
  23 
  24 #ifndef SHARE_GC_Z_ZLIST_HPP
  25 #define SHARE_GC_Z_ZLIST_HPP
  26 
  27 #include "memory/allocation.hpp"
  28 #include "utilities/macros.hpp"
  29 
  30 template <typename T> class ZList;
  31 
  32 // Element in a doubly linked list
  33 template <typename T>
  34 class ZListNode {
  35   friend class ZList<T>;
  36 
  37 private:
  38   ZListNode* _next;
  39   ZListNode* _prev;
  40 
  41   ZListNode(ZListNode* next, ZListNode* prev);
  42 
  43   void set_unused();
  44 
  45 public:
  46   ZListNode();
  47   ~ZListNode();
  48 
  49   bool is_unused() const;
  50 };
  51 
  52 // Doubly linked list
  53 template <typename T>
  54 class ZList {
  55 private:
  56   ZListNode<T> _head;
  57   size_t       _size;
  58 
  59   NONCOPYABLE(ZList);


  60 
  61   void verify() const;
  62 
  63   void insert(ZListNode<T>* before, ZListNode<T>* node);
  64 
  65   ZListNode<T>* cast_to_inner(T* elem) const;
  66   T* cast_to_outer(ZListNode<T>* node) const;
  67 
  68 public:
  69   ZList();
  70 
  71   size_t size() const;
  72   bool is_empty() const;
  73 
  74   T* first() const;
  75   T* last() const;
  76   T* next(T* elem) const;
  77   T* prev(T* elem) const;
  78 
  79   void insert_first(T* elem);


< prev index next >