Returns a read-only view of collection: reads, iteration and cursors go to the collection, so
the owner's changes show through, and every method that would change it throws
UnsupportedOperationError. The view compares by identity (equals is true only for itself),
because a collection of any family can be wrapped.
When collection is already a view this function returns (printed as UnmodifiableCollection),
it is returned unchanged. When it is any other unmodifiable view or immutable collection from
this copy of the library, the new view reads that collection's source instead, and entries it
hands out stay read-only, so read-only wrappers never nest.
Time: O(1); each operation costs what the collection's costs.
Returns a read-only view of
collection: reads, iteration and cursors go to the collection, so the owner's changes show through, and every method that would change it throwsUnsupportedOperationError. The view compares by identity (equalsistrueonly for itself), because a collection of any family can be wrapped.When
collectionis already a view this function returns (printed asUnmodifiableCollection), it is returned unchanged. When it is any other unmodifiable view or immutable collection from this copy of the library, the new view reads that collection's source instead, and entries it hands out stay read-only, so read-only wrappers never nest.Time: O(1); each operation costs what the collection's costs.