Class CnfParser

java.lang.Object
org.jacop.jasat.utils.CnfParser
All Implemented Interfaces:
Iterable<IntVec>, Iterator<IntVec>

public final class CnfParser extends Object implements Iterable<IntVec>, Iterator<IntVec>
CNF file format (low-level) parser.
Version:
4.8
  • Field Details

    • numClauses

      public int numClauses
    • numVars

      public int numVars
    • stream

      private InputStream stream
    • pool

      private MemoryPool pool
    • c

      private int c
    • nextClause

      private IntVec nextClause
    • hasGivenIterator

      private boolean hasGivenIterator
  • Constructor Details

  • Method Details

    • parseInt

      private int parseInt() throws IOException
      reads an int from the stream
      Returns:
      the parsed int
      Throws:
      IOException
    • skipComments

      private void skipComments() throws IOException
      skips comment lines from the current position
      Throws:
      IOException
    • skipLine

      private void skipLine() throws IOException
      skip the rest of the line (\n included)
      Throws:
      IOException
    • skipSpaces

      private void skipSpaces() throws IOException
      skips white spaces and carriage returns
      Throws:
      IOException
    • readProblemDef

      private void readProblemDef() throws IOException
      reads number of clauses and number of vars
      Throws:
      IOException
    • parseNextClause

      private void parseNextClause()
      parses the next clause from the stream
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<IntVec>
    • next

      public IntVec next()
      Specified by:
      next in interface Iterator<IntVec>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<IntVec>
    • iterator

      public Iterator<IntVec> iterator()
      to be called only once!
      Specified by:
      iterator in interface Iterable<IntVec>