Class Pair

java.lang.Object
dev.roanh.cpqindex.Pair
All Implemented Interfaces:
Comparable<Pair>

public final class Pair extends Object implements Comparable<Pair>
Represents a pair of two vertices, also referred to as a path or an st-pair.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    The source vertex.
    private final int
    The target vertex.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pair(int src, int trg)
    Constructs a new pair with the given source and target vertex.
    Reads a pair from the given input stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
     
    int
    Get the source vertex of this pair.
    int
    Gets the target vertex of this pair.
    int
     
    boolean
    Checks if this pair represents a loop, that is, if the source and target vertex are equivalent.
     
    void
    Write a pair to the given input stream.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • src

      private final int src
      The source vertex.
    • trg

      private final int trg
      The target vertex.
  • Constructor Details

    • Pair

      public Pair(int src, int trg)
      Constructs a new pair with the given source and target vertex.
      Parameters:
      src - The source vertex.
      trg - The target vertex.
    • Pair

      public Pair(DataInputStream in) throws IOException
      Reads a pair from the given input stream.
      Parameters:
      in - The stream to read from.
      Throws:
      IOException - When an IOException occurs.
  • Method Details

    • write

      public void write(DataOutputStream out) throws IOException
      Write a pair to the given input stream.
      Parameters:
      out - The stream to write from.
      Throws:
      IOException - When an IOException occurs.
    • getSource

      public int getSource()
      Get the source vertex of this pair.
      Returns:
      The source vertex of this pair.
    • getTarget

      public int getTarget()
      Gets the target vertex of this pair.
      Returns:
      The target vertex of thsi pair.
    • isLoop

      public boolean isLoop()
      Checks if this pair represents a loop, that is, if the source and target vertex are equivalent.
      Returns:
      True if this pair represents a loop.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Pair o)
      Specified by:
      compareTo in interface Comparable<Pair>