mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
Implement Collections#reverse
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
a61bcf824f
commit
eab3b8e448
@ -164,6 +164,15 @@ public class Collections {
|
||||
return -1 - right;
|
||||
}
|
||||
|
||||
public static <T> void reverse(List<T> list) {
|
||||
int ascending = 0, descending = list.size() - 1;
|
||||
while (ascending < descending) {
|
||||
T tmp = list.get(ascending);
|
||||
list.set(ascending++, list.get(descending));
|
||||
list.set(descending--, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static <T> T[] toArray(Collection collection, T[] array) {
|
||||
Class c = array.getClass().getComponentType();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user