Class IntegerStore

java.lang.Object
de.hdm_stuttgart.mi.sd1.store.IntegerStore

public class IntegerStore extends Object
A container holding a fixed number of integer values.
  • Constructor Details

    • IntegerStore

      public IntegerStore()
      Create a new store being able to hold integer values.
    • IntegerStore

      public IntegerStore(int capacity)
      Create a new store being able to hold integer values.
      Parameters:
      capacity - The store's initial capacity. If more values are being added via addValue(int) the capacity will be increased dynamically.
    • IntegerStore

      public IntegerStore(int[] values)
      Initializing from a given array of integers.
      Parameters:
      values - These presumably unsorted values will be sorted when being added to this store.
  • Method Details

    • getCapacity

      public int getCapacity()
      Returns:
      The number of elements the store may hold, see IntegerStore(int).
    • getNumValues

      public int getNumValues()
      Returns:
      The number of values being contained.
    • addValue

      public void addValue(int value)
      Insert a new value into our container
      Parameters:
      value - The value to be inserted. This will increment getNumValues() by one.
    • getValue

      public int getValue(int index)
      Access the value at a given index
      Parameters:
      index - The desired value's index
      Returns:
      The desired value.
      Precondition:
      index < getNumValues()
    • getValues

      public int[] getValues()
      Returns:
      The array of values entered so far
    • clear

      public void clear()
      Empty the current set of values and set the store to its initial state.
    • getAverage

      public double getAverage()
      Returns:
      The sample's average value.
    • getMedian

      public double getMedian()
      Precondition:
      There must be at least one element.
      Returns:
      The sample's median.