Documentation of 'edu.princeton.cs.algs4.StaticSETofInts' Java class
StaticSETofInts
edu.princeton.cs.algs4

Class StaticSETofInts



  • public class StaticSETofInts
    extends java.lang.Object
    The StaticSETofInts class represents a set of integers. It supports searching for a given integer is in the set. It accomplishes this by keeping the set of integers in a sorted array and using binary search to find the given integer.

    The rank and contains operations take logarithmic time in the worst case.

    For additional documentation, see Section 1.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

    • Constructor Summary

      Constructors 
      Constructor and Description
      StaticSETofInts(int[] keys)
      Initializes a set of integers specified by the integer array.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean contains(int key)
      Is the key in this set of integers?
      int rank(int key)
      Returns either the index of the search key in the sorted array (if the key is in the set) or -1 (if the key is not in the set).
      • Methods inherited from class java.lang.Object

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

      • StaticSETofInts

        public StaticSETofInts(int[] keys)
        Initializes a set of integers specified by the integer array.
        Parameters:
        keys - the array of integers
        Throws:
        java.lang.IllegalArgumentException - if the array contains duplicate integers
    • Method Detail

      • contains

        public boolean contains(int key)
        Is the key in this set of integers?
        Parameters:
        key - the search key
        Returns:
        true if the set of integers contains the key; false otherwise
      • rank

        public int rank(int key)
        Returns either the index of the search key in the sorted array (if the key is in the set) or -1 (if the key is not in the set).
        Parameters:
        key - the search key
        Returns:
        the number of keys in this set less than the key (if the key is in the set) or -1 (if the key is not in the set).

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.