• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.cooliris.media;
18 
19 import java.util.ConcurrentModificationException;
20 import java.util.Iterator;
21 
22 public class IndexRangeIterator<E> implements Iterator<E> {
23     private final E[] mList;
24     private IndexRange mRange;
25     private int mPos;
26 
IndexRangeIterator(E[] list)27     public IndexRangeIterator(E[] list) {
28         super();
29         mList = list;
30         mRange = new IndexRange();
31         mPos = mRange.begin - 1;
32     }
33 
rewind()34     public void rewind() {
35         mPos = mRange.begin - 1;
36     }
37 
setRange(int begin, int end)38     public void setRange(int begin, int end) {
39         mRange.begin = begin;
40         mRange.end = end;
41         mPos = begin - 1;
42     }
43 
getBegin()44     public int getBegin() {
45         return mRange.begin;
46     }
47 
getEnd()48     public int getEnd() {
49         return mRange.end;
50     }
51 
hasNext()52     public boolean hasNext() {
53         int pos = mPos + 1;
54         return (pos < mList.length && pos < mRange.end);
55     }
56 
getCurrentPosition()57     public int getCurrentPosition() {
58         return mPos;
59     }
60 
next()61     public E next() {
62         // TODO Auto-generated method stub
63         int pos = mPos + 1;
64         ++mPos;
65         return mList[pos];
66     }
67 
remove()68     public void remove() {
69         // TODO Auto-generated method stub
70         throw new ConcurrentModificationException();
71     }
72 
73 }
74