src/share/classes/javax/imageio/spi/DigraphNode.java
Print this page
rev 9345 : 8035487: Fix raw and unchecked lint warnings in javax.imageio.spi
Reviewed-by:
*** 37,81 ****
* to by the current node (available from <code>getOutNodes</code>).
* The in-degree of the node (that is, number of nodes that point to
* the current node) may be queried.
*
*/
! class DigraphNode implements Cloneable, Serializable {
private static final long serialVersionUID = 5308261378582246841L;
/** The data associated with this node. */
! protected Object data;
/**
* A <code>Set</code> of neighboring nodes pointed to by this
* node.
*/
! protected Set outNodes = new HashSet();
/** The in-degree of the node. */
protected int inDegree = 0;
/**
* A <code>Set</code> of neighboring nodes that point to this
* node.
*/
! private Set inNodes = new HashSet();
! public DigraphNode(Object data) {
this.data = data;
}
/** Returns the <code>Object</code> referenced by this node. */
! public Object getData() {
return data;
}
/**
* Returns an <code>Iterator</code> containing the nodes pointed
* to by this node.
*/
! public Iterator getOutNodes() {
return outNodes.iterator();
}
/**
* Adds a directed edge to the graph. The outNodes list of this
--- 37,81 ----
* to by the current node (available from <code>getOutNodes</code>).
* The in-degree of the node (that is, number of nodes that point to
* the current node) may be queried.
*
*/
! class DigraphNode<E> implements Cloneable, Serializable {
private static final long serialVersionUID = 5308261378582246841L;
/** The data associated with this node. */
! protected E data;
/**
* A <code>Set</code> of neighboring nodes pointed to by this
* node.
*/
! protected Set<DigraphNode<E>> outNodes = new HashSet<>();
/** The in-degree of the node. */
protected int inDegree = 0;
/**
* A <code>Set</code> of neighboring nodes that point to this
* node.
*/
! private Set<DigraphNode<E>> inNodes = new HashSet<>();
! public DigraphNode(E data) {
this.data = data;
}
/** Returns the <code>Object</code> referenced by this node. */
! public E getData() {
return data;
}
/**
* Returns an <code>Iterator</code> containing the nodes pointed
* to by this node.
*/
! public Iterator<DigraphNode<E>> getOutNodes() {
return outNodes.iterator();
}
/**
* Adds a directed edge to the graph. The outNodes list of this
*** 84,94 ****
* @param node a <code>DigraphNode</code>.
*
* @return <code>true</code> if the node was not previously the
* target of an edge.
*/
! public boolean addEdge(DigraphNode node) {
if (outNodes.contains(node)) {
return false;
}
outNodes.add(node);
--- 84,94 ----
* @param node a <code>DigraphNode</code>.
*
* @return <code>true</code> if the node was not previously the
* target of an edge.
*/
! public boolean addEdge(DigraphNode<E> node) {
if (outNodes.contains(node)) {
return false;
}
outNodes.add(node);
*** 103,124 ****
*
* @param node a <code>DigraphNode</code>.
*
* @return <code>true</code> if the node is the target of an edge.
*/
! public boolean hasEdge(DigraphNode node) {
return outNodes.contains(node);
}
/**
* Removes a directed edge from the graph. The outNodes list of this
* node is updated and the in-degree of the other node is decremented.
*
* @return <code>true</code> if the node was previously the target
* of an edge.
*/
! public boolean removeEdge(DigraphNode node) {
if (!outNodes.contains(node)) {
return false;
}
outNodes.remove(node);
--- 103,124 ----
*
* @param node a <code>DigraphNode</code>.
*
* @return <code>true</code> if the node is the target of an edge.
*/
! public boolean hasEdge(DigraphNode<E> node) {
return outNodes.contains(node);
}
/**
* Removes a directed edge from the graph. The outNodes list of this
* node is updated and the in-degree of the other node is decremented.
*
* @return <code>true</code> if the node was previously the target
* of an edge.
*/
! public boolean removeEdge(DigraphNode<E> node) {
if (!outNodes.contains(node)) {
return false;
}
outNodes.remove(node);
*** 130,148 ****
/**
* Removes this node from the graph, updating neighboring nodes
* appropriately.
*/
public void dispose() {
! Object[] inNodesArray = inNodes.toArray();
for(int i=0; i<inNodesArray.length; i++) {
! DigraphNode node = (DigraphNode) inNodesArray[i];
node.removeEdge(this);
}
! Object[] outNodesArray = outNodes.toArray();
for(int i=0; i<outNodesArray.length; i++) {
! DigraphNode node = (DigraphNode) outNodesArray[i];
removeEdge(node);
}
}
/** Returns the in-degree of this node. */
--- 130,150 ----
/**
* Removes this node from the graph, updating neighboring nodes
* appropriately.
*/
public void dispose() {
! @SuppressWarnings("unchecked")
! DigraphNode<E>[] inNodesArray = (DigraphNode<E>[])inNodes.toArray();
for(int i=0; i<inNodesArray.length; i++) {
! DigraphNode<E> node = inNodesArray[i];
node.removeEdge(this);
}
! @SuppressWarnings("unchecked")
! DigraphNode<E>[] outNodesArray = (DigraphNode<E>[])outNodes.toArray();
for(int i=0; i<outNodesArray.length; i++) {
! DigraphNode<E> node = outNodesArray[i];
removeEdge(node);
}
}
/** Returns the in-degree of this node. */