| 110 | } |
| 111 | |
| 112 | private synchronized Iterator |
| 113 | iterator(boolean data, boolean cycle) { |
| 114 | int size, start, total; |
| 115 | |
| 116 | total = rrs.size(); |
| 117 | |
| 118 | if (data) |
| 119 | size = total - nsigs; |
| 120 | else |
| 121 | size = nsigs; |
| 122 | if (size == 0) |
| 123 | return Collections.EMPTY_LIST.iterator(); |
| 124 | |
| 125 | if (data) { |
| 126 | if (!cycle) |
| 127 | start = 0; |
| 128 | else { |
| 129 | if (position >= size) |
| 130 | position = 0; |
| 131 | start = position++; |
| 132 | } |
| 133 | } else { |
| 134 | start = total - nsigs; |
| 135 | } |
| 136 | |
| 137 | List list = new ArrayList(size); |
| 138 | if (data) { |
| 139 | list.addAll(rrs.subList(start, size)); |
| 140 | if (start != 0) |
| 141 | list.addAll(rrs.subList(0, start)); |
| 142 | } else { |
| 143 | list.addAll(rrs.subList(start, total)); |
| 144 | } |
| 145 | |
| 146 | return list.iterator(); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Returns an Iterator listing all (data) records. |