Package de.hdm_stuttgart.mi.sd1.store
Class IntegerStore
java.lang.Object
de.hdm_stuttgart.mi.sd1.store.IntegerStore
A container holding a fixed
number of integer values.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new store being able to hold integer values.IntegerStore
(int capacity) Create a new store being able to hold integer values.IntegerStore
(int[] values) Initializing from a given array of integers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addValue
(int value) Insert a new value into our containervoid
clear()
Empty the current set of values and set the store to its initial state.double
int
double
Precondition: There must be at least one element.int
int
getValue
(int index) Access the value at a given indexint[]
-
Constructor Details
-
IntegerStore
public IntegerStore()Create a new store being able to hold integer values. -
IntegerStore
Create a new store being able to hold integer values.- Parameters:
capacity
- The store's initial capacity. If more values are being added viaaddValue(int)
the capacity will be increased dynamically.
-
IntegerStore
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
- Returns:
- The number of elements the store may
hold, see
IntegerStore(int)
.
-
getNumValues
- Returns:
- The number of values being contained.
-
addValue
Insert a new value into our container- Parameters:
value
- The value to be inserted. This will incrementgetNumValues()
by one.
-
getValue
Access the value at a given index- Parameters:
index
- The desired value's index- Returns:
- The desired value.
- Precondition:
- index <
getNumValues()
-
getValues
- Returns:
- The array of values entered so far
-
clear
Empty the current set of values and set the store to its initial state. -
getAverage
- Returns:
- The sample's average value.
-
getMedian
- Precondition:
- There must be at least one element.
- Returns:
- The sample's median.
-