com.ibm.wala.util.graph.AbstractNumberedGraph Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.ibm.wala.util Show documentation
Show all versions of com.ibm.wala.util Show documentation
T. J. Watson Libraries for Analysis
/*
* Copyright (c) 2002 - 2006 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*/
package com.ibm.wala.util.graph;
import com.ibm.wala.util.graph.impl.NumberedNodeIterator;
import com.ibm.wala.util.intset.IntSet;
import java.util.Iterator;
import org.jspecify.annotations.Nullable;
/**
* Basic functionality for a graph that delegates node and edge management, and tracks node numbers
*/
public abstract class AbstractNumberedGraph extends AbstractGraph
implements NumberedGraph {
/**
* @return the object which manages nodes in the graph
*/
@Override
protected abstract NumberedNodeManager getNodeManager();
/**
* @return the object which manages edges in the graph
*/
@Override
protected abstract NumberedEdgeManager getEdgeManager();
/**
* @see com.ibm.wala.util.graph.NumberedNodeManager#getMaxNumber()
*/
@Override
public int getMaxNumber() {
return getNodeManager().getMaxNumber();
}
/**
* @see com.ibm.wala.util.graph.NumberedNodeManager#getNode(int)
*/
@Override
public T getNode(int number) {
return getNodeManager().getNode(number);
}
/**
* @see com.ibm.wala.util.graph.NumberedNodeManager#getNumber(Object)
*/
@Override
public int getNumber(@Nullable T N) {
if (N == null) {
throw new IllegalArgumentException("N cannot be null");
}
return getNodeManager().getNumber(N);
}
/**
* @see com.ibm.wala.util.graph.NumberedNodeManager#iterateNodes(com.ibm.wala.util.intset.IntSet)
*/
@Override
public Iterator iterateNodes(final IntSet s) {
return new NumberedNodeIterator<>(s, this);
}
/**
* @see com.ibm.wala.util.graph.NumberedEdgeManager#getPredNodeNumbers(java.lang.Object)
*/
@Override
public IntSet getPredNodeNumbers(@Nullable T node) throws IllegalArgumentException {
assert getEdgeManager() != null;
return getEdgeManager().getPredNodeNumbers(node);
}
/**
* @see com.ibm.wala.util.graph.NumberedEdgeManager#getSuccNodeNumbers(java.lang.Object)
*/
@Override
public IntSet getSuccNodeNumbers(@Nullable T node) throws IllegalArgumentException {
return getEdgeManager().getSuccNodeNumbers(node);
}
}