Class ArrayUtils

java.lang.Object
it.unimi.di.prog2.s05.ArrayUtils

public class ArrayUtils extends Object
Classe di metodi di utilità per array.
  • Constructor Details

    • ArrayUtils

      private ArrayUtils()
      .
  • Method Details

    • binarySearch

      static int binarySearch(int[] haystack, int needle)
      Finds the index (or insertion point) of an integer in an array of integers in increasing order.
      • Requires: haystack is not null and is sorted in increasing order.
      • Modifies: nothing.
      • Effects: if haystack contains needle, returns the index of the first occurrence of needle in haystack; otherwise, returns -(insertion_point) - 1 where insertion_point is the index of the first integer greater than needle; note that this implies that the return value is non-negative iff haystack contains needle.