FCollection: extra get Function that checks for element in Collection

This commit is contained in:
Hanmac
2018-05-04 23:39:31 +02:00
parent ec1a4579e1
commit 018a3d8c91
2 changed files with 14 additions and 0 deletions

View File

@@ -530,6 +530,18 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
return Iterables.unmodifiableIterable(new LinkedList<T>(list));
}
@Override
public T get(final T obj) {
if (obj == null) {
return null;
}
for(T x : this) {
if (x.equals(obj)) {
return x;
}
}
return obj;
}
/**
* An unmodifiable, empty {@link FCollection}. Overrides all methods with
* default implementations suitable for an empty collection, to improve

View File

@@ -74,4 +74,6 @@ public interface FCollectionView<T> extends Iterable<T> {
* {@link Iterator#remove()}), as such an operation would have no meaning.
*/
Iterable<T> threadSafeIterable();
T get(final T obj);
}