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
The answer would be
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,