transform
Returns a collection that applies function to each element of this. The returned collection is a live view of this; changes to the base collection affects the returned one.
The returned collection isn't threadsafe or serializable, even if this is.
When a live view is not needed, it may be faster to copy the transformed collection and use the copy.
If the input Collection is known to be a List, consider Iterable.map. If only an Iterable is available, use Iterables.transform.
Stream equivalent: Stream.map.
See also
Returns a collection that applies function to each element of this. The returned collection is a live view of this; changes to the base collection affects the returned one.
The returned collection's add and addAll methods throw an {@link UnsupportedOperationException}. All other collection methods are supported, as long as {@code fromCollection} supports them.
The returned collection isn't threadsafe or serializable, even if this is.
When a live view is not needed, it may be faster to copy the transformed collection and use the copy.
If the input Collection is known to be a List, consider Iterable.map. If only an Iterable is available, use Iterables.transform.
Stream equivalent: Stream.map.
See also
Returns a view containing the result of applying function to each element of this.
If the input this is known to be a List or other Collection, consider List.transform and Collection.transform.
Stream equivalent: Stream.map
See also
Returns a view containing the result of applying function to each element of fromIterable.
The returned iterable's iterator supports remove if this's iterator does. After a successful remove call, this no longer contains the corresponding element.
If the input this is known to be a List or other Collection, consider List.transform and Collection.transform.
Stream equivalent: Stream.map
See also
Returns a view containing the result of applying function to each element of this.
See also
Returns a view containing the result of applying function to each element of this.
The returned iterator supports remove if this does. After a successful remove call, this no longer contains the corresponding element.
See also
Returns a list that applies function to each element of this. The returned list is a transformed view of this; changes to this will be reflected in the returned list and vice versa.
The function is applied lazily, invoked when needed. This is necessary for the returned list to be a view, but it means that the function will be applied many times for bulk operations like List.contains and List.hashCode. For this to perform well, function should be fast. To avoid lazy evaluation when the returned list doesn't need to be a view, copy the returned list into a new list of your choosing.
If this implements RandomAccess, so will the returned list. The returned list is threadsafe if the supplied list and function are.
If only a Collection or Iterable input is available, use Collection.transform or Iterable.transform.
Note: serializing the returned list is implemented by serializing this, its contents, and function -- not by serializing the transformed values. This can lead to surprising behavior, so serializing the returned list is not recommended. Instead, copy the list using ImmutableList.copyOf (for example), then serialize the copy. Other methods similar to this do not implement serialization at all for this reason.
Java 8 users: many use cases for this method are better addressed by Stream.map. This method is not being deprecated, but we gently encourage you to migrate to streams.
See also
Returns a list that applies function to each element of this. The returned list is a transformed view of this; changes to this will be reflected in the returned list and vice versa.
Since functions are not reversible, the transform is one-way and new items cannot be stored in the returned list. The add, addAll and set methods are unsupported in the returned list.
The function is applied lazily, invoked when needed. This is necessary for the returned list to be a view, but it means that the function will be applied many times for bulk operations like List.contains and List.hashCode. For this to perform well, function should be fast. To avoid lazy evaluation when the returned list doesn't need to be a view, copy the returned list into a new list of your choosing.
If this implements RandomAccess, so will the returned list. The returned list is threadsafe if the supplied list and function are.
If only a Collection or Iterable input is available, use Collection.transform or Iterable.transform.
Note: serializing the returned list is implemented by serializing this, its contents, and function -- not by serializing the transformed values. This can lead to surprising behavior, so serializing the returned list is not recommended. Instead, copy the list using ImmutableList.copyOf (for example), then serialize the copy. Other methods similar to this do not implement serialization at all for this reason.
Java 8 users: many use cases for this method are better addressed by Stream.map. This method is not being deprecated, but we gently encourage you to migrate to streams.