פעולות עם רשימות IntNode

public static int sumList(IntNode q){

       int sum = 0;

       while (q != null){

              sum += q.getValue();

              q = q.getNext();

       }

       return sum;

}

      

public static void printIntList(IntNode first){

       while (first != null){

              System.out.print(first.getValue()+",");

              first = first.getNext();

       }

}

      

public static void insertIntNotListAtTheEnd(IntNode first,int num){

       IntNode tmp = new IntNode(num);

       IntNode p = first;

       while (p.getNext() != null){

              p = p.getNext();

       }

       p.setNext(tmp);

}

      

public static IntNode insertToListAtStart(IntNode first,int num){

       IntNode tmp = new IntNode(num);

       tmp.setNext(first);

       return tmp;

      

}