Difference between revisions of "Slices"

From CSE231 Wiki
Jump to navigation Jump to search
Line 36: Line 36:
 
=Testing Your Solution=
 
=Testing Your Solution=
 
==Correctness==
 
==Correctness==
{{TestSuite|CountTestSuite|count.assignment}}
+
{{TestSuite|SlicesTestSuite|slice.studio}}
 
 
Launch CountTestSuite.java as a JUnit Test to run all of the tests.  CountTestSuite.java is located in src/test/java count.assignment package.  You can initiate this via right clicking on CountTestSuite.java and selecting "Run As..." -> "JUnit Test".
 
[[http://www.cse.wustl.edu/~cosgroved/courses/cse231/f17/hw1/run-junit-test-suite.png screenshot]]
 

Revision as of 06:39, 19 January 2018

Motivation

Coarsening, or n-way split as we tend to call it in this course, comes up a fair amount. This studio has you implement a utility that you can use over and over throughout the semester.

In order to support future testing well, we are strict about exactly how the data is split up among the slices.

Code to Implement

class: Slices.java Java.png
methods: createNSlicesForArrayObject
package: slices.studio
source folder: student/src/main/java

Java Utility

In order to conveniently support primitive arrays and Object arrays we will need to use the Array.getLength(Object) method.

Mistakes To Avoid

Attention niels epting.svg Warning: Do NOT Parallelize
Attention niels epting.svg Warning: Do NOT Copy The Data Into SubArrays

Background

As the name suggests, we will create a class to represent a Slice of data and a list of Slice called Slices which divides the data into a specified number of Slice given an array of data.

Where to Start

Navigate to the slice directory and look under slice.studio. You must implement Slices using the implementation of Slice given to you under the slice.core directory.

createNSlices

To create this slice, you will start at the beginning of the data array and keep creating new slices until you have numSlices which more or less evenly span the range. Remember that the sliceId should start at the zero index and the length of the list should be equal to the number of slices. Also remember that if the range is not divisible by numSlices, you must account for this by either evenly distributing the extras or making a slightly larger slice at the end of the range.

Hint: you do not need to divide up the array of data fed into the method and doing so would remove the need for a minInclusive variable for a Slice.

Javadocs

implement: Slices.createNSlices method

use: class Slice

Testing Your Solution

Correctness

class: SlicesTestSuite.java Junit.png
package: slice.studio
source folder: testing/src/test/java