mirror of
https://github.com/corda/corda.git
synced 2025-06-04 08:30:52 +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;
|
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) {
|
static <T> T[] toArray(Collection collection, T[] array) {
|
||||||
Class c = array.getClass().getComponentType();
|
Class c = array.getClass().getComponentType();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user