Java Array Sort uniqueExclusiveSort(String[] values, String[] removeValues)

Here you can find the source of uniqueExclusiveSort(String[] values, String[] removeValues)

Description

Remove from values all removeValues and build a unique sorted result array.

License

Open Source License

Parameter

Parameter Description
values to consider
removeValues values to remove from values

Return

sorted unique

Declaration

protected static String[] uniqueExclusiveSort(String[] values, String[] removeValues) 

Method Source Code

//package com.java2s;
/**************************************************************************************
 * Copyright (C) 2008 EsperTech, Inc. All rights reserved.                            *
 * http://esper.codehaus.org                                                          *
 * http://www.espertech.com                                                           *
 * ---------------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the GPL license       *
 * a copy of which has been included with this distribution in the license.txt file.  *
 **************************************************************************************/

import java.util.*;

public class Main {
    /**/*from   w  w w .  ja va 2s.c o m*/
     * Remove from values all removeValues and build a unique sorted result array.
     * @param values to consider
     * @param removeValues values to remove from values
     * @return sorted unique
     */
    protected static String[] uniqueExclusiveSort(String[] values, String[] removeValues) {
        Set<String> unique = new HashSet<String>();
        unique.addAll(Arrays.asList(values));
        for (String removeValue : removeValues) {
            unique.remove(removeValue);
        }
        String[] uniqueArr = unique.toArray(new String[unique.size()]);
        Arrays.sort(uniqueArr);
        return uniqueArr;
    }
}

Related

  1. toSortedArray(Collection collection)
  2. toSortedArray(Set groups)
  3. toSortedIntArray(Collection ints)
  4. toStringArray(Collection collection, boolean sort)
  5. union(int[] sorted1, int[] sorted2)