-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from jpage4500/feature/01-31
- open terminal if closed (on run script)
- Loading branch information
Showing
3 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/jpage4500/devicemanager/utils/ReverseIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.jpage4500.devicemanager.utils; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
/** | ||
* iterate over a list from bottom to top | ||
*/ | ||
public class ReverseIterator<T> implements Iterator<T>, Iterable<T> { | ||
|
||
private final List<T> list; | ||
private int position; | ||
|
||
public ReverseIterator(List<T> list) { | ||
this.list = list; | ||
this.position = list.size() - 1; | ||
} | ||
|
||
@Override | ||
public Iterator<T> iterator() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return position >= 0; | ||
} | ||
|
||
@Override | ||
public T next() { | ||
return list.get(position--); | ||
} | ||
|
||
@Override | ||
public void remove() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters