You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-issues@hadoop.apache.org by "Daryn Sharp (JIRA)" <ji...@apache.org> on 2017/10/13 17:22:00 UTC

[jira] [Commented] (HDFS-12653) Implement toArray() and subArray() for ReadOnlyList

    [ https://issues.apache.org/jira/browse/HDFS-12653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16203897#comment-16203897 ] 

Daryn Sharp commented on HDFS-12653:
------------------------------------

I've often wondered why does {{ReadOnlyList}} even exist?  If we keep making it act more like a standard collection, why not use a standard collection?

> Implement toArray() and subArray() for ReadOnlyList
> ---------------------------------------------------
>
>                 Key: HDFS-12653
>                 URL: https://issues.apache.org/jira/browse/HDFS-12653
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: Manoj Govindassamy
>            Assignee: Manoj Govindassamy
>
> {{ReadOnlyList}} today gives an unmodifiable view of the backing List. This list supports following Util methods for easy construction of read only views of any given list. 
> {noformat}
> public static <E> ReadOnlyList<E> asReadOnlyList(final List<E> list) 
> public static <E> List<E> asList(final ReadOnlyList<E> list)
> {noformat}
> {{asList}} above additionally overrides {{Object[] toArray()}} of the {{java.util.List}} interface. Unlike the {{java.util.List}}, the above one returns an array of Objects referring to the backing list and avoid any copying of objects. Given that we have many usages of read only lists,
> 1. Lets have a light-weight / shared-view {{toArray()}} implementation for {{ReadOnlyList}} as well. 
> 2. Additionally, similar to {{java.util.List#subList(fromIndex, toIndex)}}, lets have {{ReadOnlyList#subArray(fromIndex, toIndex)}}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org