Class BenchmarkData
java.lang.Object
com.github.rlacher.sortbench.benchmark.data.BenchmarkData
Represents benchmark data for sorting algorithms, encapsulating the data array and its type.
This class ensures immutability by creating copies of the input data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerates the types of benchmark data used for sorting algorithm benchmarking. -
Constructor Summary
ConstructorsConstructorDescriptionBenchmarkData(int[] data, BenchmarkData.DataType type) Constructor for creating a BenchmarkData object.BenchmarkData(BenchmarkData other) Copy constructor for creating aBenchmarkDataobject from anotherBenchmarkDataobject. -
Method Summary
Modifier and TypeMethodDescriptionint[]getData()Getter for the data array.intReturns the length of the data array.getType()Returns the type of the data.toString()Returns a string representation of theBenchmarkDataobject.
-
Constructor Details
-
BenchmarkData
Constructor for creating a BenchmarkData object.This constructor creates a copy of the data array to avoid external modification.
- Parameters:
data- The data array to be stored (a copy is created).type- The type of the data.- Throws:
IllegalArgumentException- If the data array isnull.
-
BenchmarkData
Copy constructor for creating aBenchmarkDataobject from anotherBenchmarkDataobject.- Parameters:
other- The otherBenchmarkDataobject to copy from.- Throws:
IllegalArgumentException- If the otherBenchmarkDataobject or its data array isnull.
-
-
Method Details
-
getData
public int[] getData()Getter for the data array.- Returns:
- Returns the same instance of the data array (no copying).
-
getLength
public int getLength()Returns the length of the data array.Benchmark data of various lengths are required for performance assessment of the sorting algorithms.
- Returns:
- The length of the data array.
-
getType
Returns the type of the data.Benchmark data of various types help assess the performance of sorting algorithms.
- Returns:
- The type of the data array.
-
toString
Returns a string representation of theBenchmarkDataobject.- Overrides:
toStringin classObject- Returns:
- A string representation of the
BenchmarkDataobject.
-