"While Loop"
Hello,
Is there a possibility to loop through Example set with sort of "while" loop?
It seems to me that for-loop is not the most efficient solution for the following problem that I am trying to solve.
I have two tables A and B. Table A has Time1 attribute and Table B has Time2 and EventsCount attributes. Entries in tables A and B are sorted according to the Time1 and Time2 respectively.
Moreover time entries in table A are periodic with period p. I would like to find out how many events from table B (stored in EventsCount) correspond to every Time1 element from table A. For example, if we have
TableA(Time1)
3
13
23
33
43
TableB(Time2,EventsCount)
4,7
8,1
10,4
15,2
21,5
30,10
36,11
40,2
The answer would be
3,7+1=8
13,4+2=7
23,5
33,10+11=21
43,2
To obtain the result the program has to loop over Time1 attribute in Table A and count all the values from EventsCount column which have Time2 value grater than Time1-p/2 and less than Time1+p/2. Therefore there are two loops, first for Table A and second for Table B. It would be more efficient to implement the second loop as a while loop because we would not have to scan all the elements in table B in this case, but we would only scan the table once.
So, do I have to use For-Loop for that? Any idea about the process to solve the described problem?
Thank you for help,
Szymon