Ejemplo n.º 1
0
 protected void processRange(TreeSet<Range> tree, Range treeRange, Range newRange) {
   if (treeRange.getLeft() >= newRange.getRight()) {
     tree.add(newRange);
   } else if (treeRange.getRight() >= newRange.getLeft()) {
     tree.add(newRange);
   } else {
     System.out.println("Oops" + treeRange.toString() + newRange.toString());
   }
 }
Ejemplo n.º 2
0
  public void run(String fileName) {
    this.fileName = fileName;

    tree = new TreeSet<Range>(new RangeComparator());

    try {
      BufferedReader bis = new BufferedReader(new FileReader(fileName));

      String line;

      while ((line = bis.readLine()) != null) {
        processLine(line);
      }

      System.out.println("-----");

      for (Range r : tree) {
        System.out.println(r.toString());
      }
    } catch (FileNotFoundException ex) {
      System.err.println(ex.toString());
    } catch (IOException ex) {
      System.err.println(ex.toString());
    }
  }