Documentation of 'edu.rit.util.Searching' Java class
Searching
edu.rit.util

Class Searching



  • public class Searching
    extends java.lang.Object
    Class Searching provides static methods for searching arrays of primitive types and object types.

    Note: The operations in class Searching are not multiple thread safe.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  Searching.Byte
      Class Searching.Byte is the base class for a helper object used to search an array of type byte[].
      static class  Searching.Character
      Class Searching.Character is the base class for a helper object used to search an array of type char[].
      static class  Searching.Double
      Class Searching.Double is the base class for a helper object used to search an array of type double[].
      static class  Searching.Float
      Class Searching.Float is the base class for a helper object used to search an array of type float[].
      static class  Searching.Integer
      Class Searching.Integer is the base class for a helper object used to search an array of type int[].
      static class  Searching.Long
      Class Searching.Long is the base class for a helper object used to search an array of type long[].
      static class  Searching.Object<T>
      Class Searching.Object is the base class for a helper object used to search an array of type T[].
      static class  Searching.Short
      Class Searching.Short is the base class for a helper object used to search an array of type short[].
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static int searchSorted(byte[] x, byte a, Searching.Byte helper)
      Search the given ordered array of type byte[] for the given element.
      static int searchSorted(char[] x, char a, Searching.Character helper)
      Search the given ordered array of type char[] for the given element.
      static int searchSorted(double[] x, double a, Searching.Double helper)
      Search the given ordered array of type double[] for the given element.
      static int searchSorted(float[] x, float a, Searching.Float helper)
      Search the given ordered array of type float[] for the given element.
      static int searchSorted(int[] x, int a, Searching.Integer helper)
      Search the given ordered array of type int[] for the given element.
      static int searchSorted(long[] x, long a, Searching.Long helper)
      Search the given ordered array of type long[] for the given element.
      static int searchSorted(short[] x, short a, Searching.Short helper)
      Search the given ordered array of type short[] for the given element.
      static <T extends java.lang.Comparable>
      int
      searchSorted(T[] x, T a)
      Search the given ordered array of type T[] for the given element.
      static <T> int searchSorted(T[] x, T a, java.util.Comparator<T> comp)
      Search the given ordered array of type T[] for the given element.
      static <T> int searchSorted(T[] x, T a, Searching.Object<T> helper)
      Search the given ordered array of type T[] for the given element.
      static int searchUnsorted(byte[] x, byte a, Searching.Byte helper)
      Search the given unordered array of type byte[] for the given element.
      static int searchUnsorted(char[] x, char a, Searching.Character helper)
      Search the given unordered array of type char[] for the given element.
      static int searchUnsorted(double[] x, double a, Searching.Double helper)
      Search the given unordered array of type double[] for the given element.
      static int searchUnsorted(float[] x, float a, Searching.Float helper)
      Search the given unordered array of type float[] for the given element.
      static int searchUnsorted(int[] x, int a, Searching.Integer helper)
      Search the given unordered array of type int[] for the given element.
      static int searchUnsorted(long[] x, long a, Searching.Long helper)
      Search the given unordered array of type long[] for the given element.
      static int searchUnsorted(short[] x, short a, Searching.Short helper)
      Search the given unordered array of type short[] for the given element.
      static <T extends java.lang.Comparable>
      int
      searchUnsorted(T[] x, T a)
      Search the given unordered array of type T[] for the given element.
      static <T> int searchUnsorted(T[] x, T a, java.util.Comparator<T> comp)
      Search the given unordered array of type T[] for the given element.
      static <T> int searchUnsorted(T[] x, T a, Searching.Object<T> helper)
      Search the given unordered array of type T[] for the given element.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • searchUnsorted

        public static int searchUnsorted(byte[] x,
                                         byte a,
                                         Searching.Byte helper)
        Search the given unordered array of type byte[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static int searchSorted(byte[] x,
                                       byte a,
                                       Searching.Byte helper)
        Search the given ordered array of type byte[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static int searchUnsorted(char[] x,
                                         char a,
                                         Searching.Character helper)
        Search the given unordered array of type char[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static int searchSorted(char[] x,
                                       char a,
                                       Searching.Character helper)
        Search the given ordered array of type char[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static int searchUnsorted(short[] x,
                                         short a,
                                         Searching.Short helper)
        Search the given unordered array of type short[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static int searchSorted(short[] x,
                                       short a,
                                       Searching.Short helper)
        Search the given ordered array of type short[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static int searchUnsorted(int[] x,
                                         int a,
                                         Searching.Integer helper)
        Search the given unordered array of type int[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static int searchSorted(int[] x,
                                       int a,
                                       Searching.Integer helper)
        Search the given ordered array of type int[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static int searchUnsorted(long[] x,
                                         long a,
                                         Searching.Long helper)
        Search the given unordered array of type long[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static int searchSorted(long[] x,
                                       long a,
                                       Searching.Long helper)
        Search the given ordered array of type long[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static int searchUnsorted(float[] x,
                                         float a,
                                         Searching.Float helper)
        Search the given unordered array of type float[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static int searchSorted(float[] x,
                                       float a,
                                       Searching.Float helper)
        Search the given ordered array of type float[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static int searchUnsorted(double[] x,
                                         double a,
                                         Searching.Double helper)
        Search the given unordered array of type double[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static int searchSorted(double[] x,
                                       double a,
                                       Searching.Double helper)
        Search the given ordered array of type double[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static <T> int searchUnsorted(T[] x,
                                             T a,
                                             Searching.Object<T> helper)
        Search the given unordered array of type T[] for the given element. The given helper object is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Type Parameters:
        T - Array element data type.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static <T> int searchSorted(T[] x,
                                           T a,
                                           Searching.Object<T> helper)
        Search the given ordered array of type T[] for the given element. The given helper object is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the helper object; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Type Parameters:
        T - Array element data type.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        helper - Helper object.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static <T> int searchUnsorted(T[] x,
                                             T a,
                                             java.util.Comparator<T> comp)
        Search the given unordered array of type T[] for the given element. The given comparator is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Type Parameters:
        T - Array element data type.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        comp - Comparator.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static <T> int searchSorted(T[] x,
                                           T a,
                                           java.util.Comparator<T> comp)
        Search the given ordered array of type T[] for the given element. The given comparator is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the comparator; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Type Parameters:
        T - Array element data type.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        comp - Comparator.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchUnsorted

        public static <T extends java.lang.Comparable> int searchUnsorted(T[] x,
                                                                          T a)
        Search the given unordered array of type T[] for the given element. The array element's natural ordering (compareTo() method) is used to compare elements for equality only. An O(n) linear search algorithm is used.
        Type Parameters:
        T - Array element data type.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.
      • searchSorted

        public static <T extends java.lang.Comparable> int searchSorted(T[] x,
                                                                        T a)
        Search the given ordered array of type T[] for the given element. The array element's natural ordering (compareTo() method) is used to compare elements for order and equality. It is assumed that the array is sorted in the order determined by the natural ordering; otherwise, the searchSorted() method's behavior is not specified. An O(log n) binary search algorithm is used.
        Type Parameters:
        T - Array element data type.
        Parameters:
        x - Array to be searched.
        a - Element to be searched for.
        Returns:
        If an element the same as a exists in x, then the index of that element is returned. Otherwise, −1 is returned.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.