All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.wala.util.graph.AbstractNumberedGraph Maven / Gradle / Ivy

There is a newer version: 1.6.9
Show newest version
/*
 * 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);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy