Example #1
0
    public static void main(String[] args) {
      ClauseInfo first =
          new ClauseInfo(new Struct(new Struct("First"), new Struct("First")), "First Element");
      ClauseInfo second =
          new ClauseInfo(new Struct(new Struct("Second"), new Struct("Second")), "Second Element");
      ClauseInfo third =
          new ClauseInfo(new Struct(new Struct("Third"), new Struct("Third")), "Third Element");
      ClauseInfo fourth =
          new ClauseInfo(new Struct(new Struct("Fourth"), new Struct("Fourth")), "Fourth Element");

      clauseList.add(first);
      clauseList.add(second);
      clauseList.add(third);
      clauseList.add(fourth);

      // clauseList = [First, Second, Third, Fourh]
      ListIterator<ClauseInfo> allClauses = clauseList.listIterator();
      // Get the first object and remove it
      allClauses.next();
      allClauses.remove();
      if (clauseList.contains(first)) {
        System.out.println("Error!");
        System.exit(-1);
      }

      // First object removed
      // clauseList = [Second, Third, Fourh]
      // Get the second object
      allClauses.next();
      // Get the third object
      allClauses.next();
      // Get the third object
      allClauses.previous();
      // Get the second object and remove it
      allClauses.previous();
      allClauses.remove();
      if (clauseList.contains(second)) {
        System.out.println("Error!");
        System.exit(-2);
      }

      // clauseList = [Third, Fourh]
      System.out.println("Ok!!!");
    }
Example #2
0
 public ListItr(FamilyClausesList list, int index) {
   l = list;
   it = list.superListIterator(index);
 }