Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 6683 invoked from network); 20 May 2008 05:01:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 May 2008 05:01:20 -0000 Received: (qmail 97337 invoked by uid 500); 20 May 2008 05:01:21 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 96886 invoked by uid 500); 20 May 2008 05:01:20 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 96875 invoked by uid 99); 20 May 2008 05:01:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 May 2008 22:01:20 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 May 2008 05:00:34 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A94CF234C118 for ; Mon, 19 May 2008 22:00:55 -0700 (PDT) Message-ID: <617394008.1211259655692.JavaMail.jira@brutus> Date: Mon, 19 May 2008 22:00:55 -0700 (PDT) From: "Julius Davies (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (COLLECTIONS-296) Introduce SortedUtils.merge() for merging sorted collections In-Reply-To: <53589959.1210999796444.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COLLECTIONS-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598173#action_12598173 ] Julius Davies commented on COLLECTIONS-296: ------------------------------------------- Thanks very much for the feedback! I worry that consumer won't properly initialize Collection "res" to the right capacity (a.size() + b.size()). Also, if the consumer wants to put the elements in a different collection, they can always use Collection.addAll() with the ArrayList that's returned. Here are some more methods I'm thinking of adding: boolean isSorted(Collection coll); boolean isSorted(Collection coll, Comparator c); int binarySearch(List l, Object o); int binarySearch(List l, Object o, Comparator c); There's another reason I like returning ArrayList: it can be easily fed into the binarySearch() method I'm thinking of adding. LinkedList *can* be fed into binarySearch, but it's a bad idea! > 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.