| OLD | NEW |
| 1 /** | 1 /** |
| 2 * An iterator that allows the user to move forward and backward though | 2 * An iterator that allows the user to move forward and backward though |
| 3 * a set of items. (Bi-directional) | 3 * a set of items. (Bi-directional) |
| 4 */ | 4 */ |
| 5 class BiIterator<E> { | 5 class BiIterator<E> { |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Provides forward and backward iterator functionality to keep track | 8 * Provides forward and backward iterator functionality to keep track |
| 9 * which item is currently selected. | 9 * which item is currently selected. |
| 10 */ | 10 */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 if (currentIndex.value < list.length - 1) { | 30 if (currentIndex.value < list.length - 1) { |
| 31 currentIndex.value += 1; | 31 currentIndex.value += 1; |
| 32 } | 32 } |
| 33 return list[currentIndex.value]; | 33 return list[currentIndex.value]; |
| 34 } | 34 } |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Returns the current Section (page in the UI) that the user is | 37 * Returns the current Section (page in the UI) that the user is |
| 38 * looking at. | 38 * looking at. |
| 39 */ | 39 */ |
| 40 E get current() { | 40 E get current { |
| 41 return list[currentIndex.value]; | 41 return list[currentIndex.value]; |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Returns the previous section from the sections, given the current | 45 * Returns the previous section from the sections, given the current |
| 46 * position. Returns the front section if we are already at the front of | 46 * position. Returns the front section if we are already at the front of |
| 47 * the list. | 47 * the list. |
| 48 */ | 48 */ |
| 49 E previous() { | 49 E previous() { |
| 50 if (currentIndex.value > 0) { | 50 if (currentIndex.value > 0) { |
| 51 currentIndex.value -= 1; | 51 currentIndex.value -= 1; |
| 52 } | 52 } |
| 53 return list[currentIndex.value]; | 53 return list[currentIndex.value]; |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Move the iterator pointer over so that it points to a given list item. | 57 * Move the iterator pointer over so that it points to a given list item. |
| 58 */ | 58 */ |
| 59 void jumpToValue(E val) { | 59 void jumpToValue(E val) { |
| 60 for (int i = 0; i < list.length; i++) { | 60 for (int i = 0; i < list.length; i++) { |
| 61 if (list[i] === val) { | 61 if (list[i] === val) { |
| 62 currentIndex.value = i; | 62 currentIndex.value = i; |
| 63 break; | 63 break; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| OLD | NEW |