פעולות סטטיות גנריות – 08.10.2018

public static <T>  int countList(Node<T> first){

       int count = 0;

       while (first != null){

              count++;

              first = first.getNext();

       }

       return count;

}

 

public static <T> boolean isInList(Node<T> p, T x){

       while (p != null){

              if (p.getValue().equals(x)){

                     return true;

              }

              p = p.getNext();

       }

       return false;

}