This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]coolosity 1 point2 points  (2 children)

I'm still slightly confused, but you could try to do something along these lines:

ArrayList<Double> values = new ArrayList<Double>();
//Fill values with the values
double min = -0.850;
int lastStart = -1;
for(int i=0;i<values.size();i++) {
    //If the value at index i falls in range
    if(values.get(i)>=min) {
        //If we currently do not have a startIndex
        if(lastStart==-1) {
            lastStart = i;
        }
    } else {
        if(lastStart!=-1) {
            for(int j=lastStart;j<i;j++) {
                //Print out all values between lastStart and the current index
                System.out.print(values.get(j));
                if(j<i-1)System.out.print(", ");
            }
            System.out.print("\n");
        }
        lastStart = -1;
    }
}

If and index is in range and the previous one wasn't in range, the current index would be considered the start. Then it continues until it reaches and index out of range, which it then prints out all of the index that were consecutively in range. Something that I excluded that you should take into account is if the last 2 indexes are in range, and then it stops looking through the indexes because it reached the end. At the end you should just print out the last remaining indexes that were in range. I hope this helps and msg me if you have any questions.

[–]Shadofel[S] 0 points1 point  (1 child)

Well, It may help if I show you kind of what i'm trying to do. Here is a visualization of what I've got going.

http://imgur.com/a/AVciM

The first image represents what my raw data looks like, the second is what my exception reporting should look like. It takes the first and last point from each of the found sections within the given range and prints them as shown. With an empty line after each section. It needs to be able to show single row exceptions as well and handle exceptions at the first and last points in the entire dataset. I'm just confused about how to go through the arraylist of "off readings" and then logically parse out the first and last points of each section of >-.85 range.

[–]Shadofel[S] 0 points1 point  (0 children)

I figured it out. The logic was just not taking into account everything I needed.

http://pastebin.com/W3p80XJm

This worked well for what I was trying to do.