Java List Sort sortedUnion(List args1, List args2)

Here you can find the source of sortedUnion(List args1, List args2)

Description

sorted Union

License

Open Source License

Declaration

public static List sortedUnion(List args1, List args2) 

Method Source Code

//package com.java2s;
/* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept.
 This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit).
 http://www.cs.umass.edu/~mccallum/mallet
 This software is provided under the terms of the Common Public License,
 version 1.0, as published by http://www.opensource.org.  For further
 information, see the file `LICENSE' included with this distribution. */

import java.util.*;

public class Main {
    public static List sortedUnion(List args1, List args2) {
        SortedSet set = new TreeSet();
        set.addAll(args1);//from w  w  w. j  a  va 2  s.c  om
        set.addAll(args2);

        List lst = new ArrayList(set.size());
        for (Iterator it = set.iterator(); it.hasNext();) {
            Object o = it.next();
            lst.add(o);
        }

        return lst;
    }
}

Related

  1. sorted(List l)
  2. sortedArray(List list)
  3. sortedInsert(List list, E e, Comparator c)
  4. sortedInsert(List list, T item, Comparator comparator)
  5. sortedList(List list)
  6. sortEntrySetToList(Set> set)
  7. sortIds(List ids)
  8. sortIfUnsorted(List genomes)
  9. sortInputQueryKeys(List l)

  10. HOME | Copyright © www.java2s.com 2016