mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 11:27:57 +01:00
Add documentation to CollectionUtils methods
This commit is contained in:
parent
376e234baf
commit
2f44621657
1 changed files with 21 additions and 0 deletions
|
@ -15,6 +15,13 @@ public final class CollectionUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all items returned by the {@link Iterator} as a {@link List}.
|
||||||
|
*
|
||||||
|
* @param iterator iterator
|
||||||
|
* @param <I> type
|
||||||
|
* @return list
|
||||||
|
*/
|
||||||
public static <I> List<I> iteratorToList(Iterator<I> iterator) {
|
public static <I> List<I> iteratorToList(Iterator<I> iterator) {
|
||||||
List<I> items = new ArrayList<>();
|
List<I> items = new ArrayList<>();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -24,6 +31,13 @@ public final class CollectionUtils {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new array which contains <pre>t</pre> as first element, followed by the elements of <pre>ts</pre>.
|
||||||
|
* @param t head
|
||||||
|
* @param ts tail
|
||||||
|
* @param <T> type
|
||||||
|
* @return t and ts as array
|
||||||
|
*/
|
||||||
public static <T> T[] concat(T t, T[] ts) {
|
public static <T> T[] concat(T t, T[] ts) {
|
||||||
T[] concat = (T[]) Array.newInstance(t.getClass(), ts.length + 1);
|
T[] concat = (T[]) Array.newInstance(t.getClass(), ts.length + 1);
|
||||||
concat[0] = t;
|
concat[0] = t;
|
||||||
|
@ -31,6 +45,13 @@ public final class CollectionUtils {
|
||||||
return concat;
|
return concat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true, if the given array <pre>ts</pre> contains the element <pre>t</pre>.
|
||||||
|
* @param ts elements
|
||||||
|
* @param t searched element
|
||||||
|
* @param <T> type
|
||||||
|
* @return true if ts contains t, false otherwise
|
||||||
|
*/
|
||||||
public static <T> boolean contains(T[] ts, T t) {
|
public static <T> boolean contains(T[] ts, T t) {
|
||||||
for (T i : ts) {
|
for (T i : ts) {
|
||||||
if (i.equals(t)) {
|
if (i.equals(t)) {
|
||||||
|
|
Loading…
Reference in a new issue