[jira] [Comment Edited] (COLLECTIONS-605) Add new CollectionUtils Feature - addNCopies

2017-06-27 Thread Sebb (JIRA)

[ 
https://issues.apache.org/jira/browse/COLLECTIONS-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16064035#comment-16064035
 ] 

Sebb edited comment on COLLECTIONS-605 at 6/27/17 11:53 AM:


Here is the example that inspired me:
{code:title=org.apache.hadoop.hive.serde2.RegexSerDe}
 row = new ArrayList(numColumns);
// Constructing the row object, etc, which will be reused for all rows.
for (int c = 0; c < numColumns; c++) {
  row.add(null);
}
{code}

What it would be nice to do:
{code:title=org.apache.hadoop.hive.serde2.RegexSerDe}
 row = new ArrayList(numColumns);
 CollectionUtils.addNCopies(row, numColumns, null);
{code}


was (Author: belugabehr):
Here is the example that inspired me:
{code:title=org.apache.hadoop.hive.serde2.RegexSerDe}
 row = new ArrayList(numColumns);
// Constructing the row object, etc, which will be reused for all rows.
for (int c = 0; c < numColumns; c++) {
  row.add(null);
}
{code}

What it would be nice to do:
{code:title=org.apache.hadoop.hive.serde2.RegexSerDe}
 row = new ArrayList(numColumns);
 CollectionUtils.addNCopies(numColumns, null);
{code}

> Add new CollectionUtils Feature - addNCopies
> 
>
> Key: COLLECTIONS-605
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-605
> Project: Commons Collections
>  Issue Type: New Feature
>Affects Versions: 4.1
>Reporter: BELUGA BEHR
>Priority: Trivial
> Attachments: COLLECTIONS-605.1.patch
>
>
> Java's {{java.util.Collections}} has:
> {code}
> nCopies(int n, T o)
> Returns an immutable list consisting of n copies of the specified object.
> addAll(Collection c, T... elements)
> Adds all of the specified elements to the specified collection.
> fill(List list, T obj)
> Replaces all of the elements of the specified list with the specified element.
> {code}
> However, it does not have the ability to add nCopies directly to a Collection.



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


[jira] [Comment Edited] (COLLECTIONS-605) Add new CollectionUtils Feature - addNCopies

2017-06-26 Thread BELUGA BEHR (JIRA)

[ 
https://issues.apache.org/jira/browse/COLLECTIONS-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16064035#comment-16064035
 ] 

BELUGA BEHR edited comment on COLLECTIONS-605 at 6/27/17 12:25 AM:
---

Here is the example that inspired me:
{code:title=org.apache.hadoop.hive.serde2.RegexSerDe}
 row = new ArrayList(numColumns);
// Constructing the row object, etc, which will be reused for all rows.
for (int c = 0; c < numColumns; c++) {
  row.add(null);
}
{code}

What it would be nice to do:
{code:title=org.apache.hadoop.hive.serde2.RegexSerDe}
 row = new ArrayList(numColumns);
 CollectionUtils.addNCopies(numColumns, null);
{code}


was (Author: belugabehr):
{code:title=org.apache.hadoop.hive.serde2.RegexSerDe}
 row = new ArrayList(numColumns);
// Constructing the row object, etc, which will be reused for all rows.
for (int c = 0; c < numColumns; c++) {
  row.add(null);
}
{code}

> Add new CollectionUtils Feature - addNCopies
> 
>
> Key: COLLECTIONS-605
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-605
> Project: Commons Collections
>  Issue Type: New Feature
>Affects Versions: 4.1
>Reporter: BELUGA BEHR
>Priority: Trivial
> Attachments: COLLECTIONS-605.1.patch
>
>
> Java's {{java.util.Collections}} has:
> {code}
> nCopies(int n, T o)
> Returns an immutable list consisting of n copies of the specified object.
> addAll(Collection c, T... elements)
> Adds all of the specified elements to the specified collection.
> fill(List list, T obj)
> Replaces all of the elements of the specified list with the specified element.
> {code}
> However, it does not have the ability to add nCopies directly to a Collection.



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