< prev index next >

src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java

Print this page


   1 /*
   2  * Copyright (c) 2008, 2015, 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  *


  73     }
  74 
  75     InputBlock(InputGraph graph, String name) {
  76         this.graph = graph;
  77         this.name = name;
  78         nodes = new ArrayList<>();
  79         successors = new LinkedHashSet<>(2);
  80     }
  81 
  82     public String getName() {
  83         return name;
  84     }
  85 
  86     public List<InputNode> getNodes() {
  87         return Collections.unmodifiableList(nodes);
  88     }
  89 
  90     public void addNode(int id) {
  91         InputNode node = graph.getNode(id);
  92         assert node != null;
  93         assert !nodes.contains(node) : "duplicate : " + node;


  94         graph.setBlock(node, this);
  95         nodes.add(node);
  96     }
  97 
  98     public Set<InputBlock> getSuccessors() {
  99         return Collections.unmodifiableSet(successors);
 100     }
 101 
 102     @Override
 103     public String toString() {
 104         return "Block " + this.getName();
 105     }
 106 
 107     void addSuccessor(InputBlock b) {
 108         if (!successors.contains(b)) {
 109             successors.add(b);
 110         }
 111     }
 112 }
   1 /*
   2  * Copyright (c) 2008, 2016, 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  *


  73     }
  74 
  75     InputBlock(InputGraph graph, String name) {
  76         this.graph = graph;
  77         this.name = name;
  78         nodes = new ArrayList<>();
  79         successors = new LinkedHashSet<>(2);
  80     }
  81 
  82     public String getName() {
  83         return name;
  84     }
  85 
  86     public List<InputNode> getNodes() {
  87         return Collections.unmodifiableList(nodes);
  88     }
  89 
  90     public void addNode(int id) {
  91         InputNode node = graph.getNode(id);
  92         assert node != null;
  93         // nodes.contains(node) is too expensive for large graphs so
  94         // just make sure the Graph doesn't know it yet.
  95         assert graph.getBlock(id) == null : "duplicate : " + node;
  96         graph.setBlock(node, this);
  97         nodes.add(node);
  98     }
  99 
 100     public Set<InputBlock> getSuccessors() {
 101         return Collections.unmodifiableSet(successors);
 102     }
 103 
 104     @Override
 105     public String toString() {
 106         return "Block " + this.getName();
 107     }
 108 
 109     void addSuccessor(InputBlock b) {
 110         if (!successors.contains(b)) {
 111             successors.add(b);
 112         }
 113     }
 114 }
< prev index next >