Class BoundedArray<E>


  • public class BoundedArray<E>
    extends java.lang.Object
    Provides an implementation of a bounded array that supports generic programming.
    • Constructor Summary

      Constructors 
      Constructor Description
      BoundedArray​(int len)
      Creates a bounded array whose length is the input len, and whose entries are all null, if len is a positive integer - throwing an IllegalArgumentException if len is less than or equal to zero

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      E get​(int index)
      Returns the entry at a given index, if that index is non-negative and less than the length of this bounded array - throwing an ArrayIndexOutOfBoundsException otherwise.
      int length()
      Returns the length of this bounded array

      void set​(int index, E value)
      Sets the entry at a given index to be a given value, if the index is non-negative and less than the length of this bounded array - throwing an ArrayIndexOutOfBoundsException otherwise.
      • Methods inherited from class java.lang.Object

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

      • BoundedArray

        public BoundedArray​(int len)
        Creates a bounded array whose length is the input len, and whose entries are all null, if len is a positive integer - throwing an IllegalArgumentException if len is less than or equal to zero

        Parameters:
        len - the length of the Array to be created
    • Method Detail

      • get

        public E get​(int index)
        Returns the entry at a given index, if that index is non-negative and less than the length of this bounded array - throwing an ArrayIndexOutOfBoundsException otherwise.

        Parameters:
        index - the index of the array entry to be returned
        Returns:
        the value at the input index
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the index is negative, or greater than or equal to the length of this bounded array
      • set

        public void set​(int index,
                        E value)
        Sets the entry at a given index to be a given value, if the index is non-negative and less than the length of this bounded array - throwing an ArrayIndexOutOfBoundsException otherwise.

        Parameters:
        index - the index of the array whose value is to be set
        value - the new value for this entry of the bounded array
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the index is negative, or greater than or equal to the length of this bounded array
      • length

        public int length()
        Returns the length of this bounded array

        Returns:
        the length of this bounded array