You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[collect] Add method to get i-th element of Collections
This change adds a new method `Collections2.getElement(Collection, int)`, which
returns the i-th element of the collection.
Unlike existing methods via Java `Stream` or `Iterable`, the method in this
change supports fast access for `ImmutableCollection`s backed by an internal
array in `O(1)` instead of `O(n)` with the existing approach.
Users can use this method to, e.g., retrieve a random element from
`ImmutableSet` (e.g., to select a random node to connect to from a pool of
nodes in a distributed system).
0 commit comments