Class SparseMatrix


  • public final class SparseMatrix
    extends Object
    Generic Class for sparsely populated matrices. The size of the matrix is dynamic, i.e. you can specify arbitrary row and column parameters. Another way to look at this class is as a "two-dimensional" map. Instead of a single key it uses a row and a column element to store and retrieve data elements. The public Interface Traverser allows to traverse the matrix generically. The Traverser object is passed into traverse(Traverser) and is given the opportunity to work with each element of the matrix.
    • Constructor Detail

      • SparseMatrix

        public SparseMatrix​(int size1,
                            int size2)
    • Method Detail

      • getRow

        public List<Pair> getRow​(int row)
      • getCol

        public List<Pair> getCol​(int col)
      • g

        public Pair g​(int row,
                      int col)
        Returns the value found at the specified row and column of the matrix. Returns null if there's no value for the specified row and column.
        Parameters:
        row - Object
        col - Object
        Returns:
        Object
      • set

        public void set​(int row,
                        int col,
                        int value)
        Sets the value of the matrix at the specified row and column.
        Parameters:
        row - Object
        col - Object
        value - a value
      • setNoUpdate

        public void setNoUpdate​(int row,
                                int col,
                                int value)
      • remove

        public void remove​(int row,
                           int col)
      • colSet

        public Set<Integer> colSet()
        Returns a Set of all used "columns" in the matrix.
        Returns:
        Set
      • rowSet

        public Set<Integer> rowSet()
        Returns a Set of all used "rows" in the matrix.
        Returns:
        Set
      • clear

        public void clear()
      • hashCode

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

        public void floydWarshall​(SparseMatrix next)
      • getMaximum

        public int getMaximum()
      • isNonStrictOrdering

        public static final boolean isNonStrictOrdering​(int n)
      • addAndPreserveStrictOrdering

        public final int addAndPreserveStrictOrdering​(int n1,
                                                      int n2)
      • roundedOrder

        public final int roundedOrder​(int n)
      • floydWarshallWithIterator

        public final void floydWarshallWithIterator​(SparseMatrix next)