mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
Add Collections#singletonList
This is a very dumb implementation that wastes space and time by constructing a full-blown ArrayList as backend. However, it is better to have a dumb implementation than none at all, and we can always do something about the performance when, and if, that should become necessary. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
86c735e649
commit
056c65947e
@ -659,4 +659,10 @@ public class Collections {
|
||||
return - cmp.compare(o1, o2);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<T> singletonList(T o) {
|
||||
ArrayList<T> list = new ArrayList<T>(1);
|
||||
list.add(o);
|
||||
return new UnmodifiableList(list);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user