public void registerElement(int n){
  if (first) {
    first=false;
    last=n - 1;
  }
  if (max < n)   max=n;
  if (min > n)   min=n;
  if (n == last)   duplicates++;
  count++;
  int distance=n - last;
  ordering+=Math.abs(distance - 1);
  last=n;
}

public void registerElement ( int n ) { if ( first ) { first = false ; last = n - 1 ; } if ( max < n ) max = n ; if ( min > n ) min = n ; if ( n == last ) duplicates ++ ; count ++ ; int distance = n - last ; ordering += Math . abs ( distance - 1 ) ; last = n ; }
note that this is not synchronized and should be called with attention paid to any multi - threaded use .
