You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Julien Aymé (JIRA)" <ji...@apache.org> on 2008/05/19 13:29:55 UTC

[jira] Commented: (COLLECTIONS-296) Introduce SortedUtils.merge() for merging sorted collections

    [ https://issues.apache.org/jira/browse/COLLECTIONS-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597924#action_12597924 ] 

Julien Aymé commented on COLLECTIONS-296:
-----------------------------------------

This method sounds interesting, but instead of sticking to ArrayList implementation, I would rather add a new parameter which would be the Collection to merge into:
{code}
/**
 * Merges the sorted Collections a and b into the empty Collection res
 * and return result.
 * <p>
 * The collections a and b are combined such that ordering of the elements according to
 * Comparator c is retained. Uses the standard O(n) merge algorithm for combining two sorted lists.
 *
 * @param a The first sorted Collection to merge
 * @param b The secong sorted Collection to merge
 * @param res an empty Collection to merge into
 * @param c Comparator by which Collection a and Collection b have been sorted, or null
 * if the Collections are sorted according to their natural ordering.
 * @return res in which the merge has been done
{code}

> Introduce SortedUtils.merge() for merging sorted collections
> ------------------------------------------------------------
>
>                 Key: COLLECTIONS-296
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-296
>             Project: Commons Collections
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Julius Davies
>            Priority: Minor
>         Attachments: SortedUtils.patch
>
>
> Is there any interest in this?
>     /**
>      * Returns a new ArrayList where sorted Collection a and sorted Collection b
>      * are combined such that ordering of the elements according to
>      * Comparator c is retained.  Uses the standard O(n) merge algorithm
>      * for combining two sorted lists.
>      *
>      * @param a Object to combine with sorted Collection b.  Must implement Comparable.
>      * @param b Sorted Collection to combine with Object a.
>      * @param c Comparator by which Collection a and Collection b have been sorted, or null
>      *          if the Collections are sorted according to their natural ordering.
>      * @return a new sorted ArrayList
>      */
>     public static ArrayList merge(Collection a, Collection b, Comparator c);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.