Java Utililty Methods List Distinct Value

List of utility methods to do List Distinct Value

Description

The list of methods to do List Distinct Value are organized into topic(s).

Method

booleanaddDistinctEntry(List sourceList, V entry)
add distinct entry to list
return (sourceList != null && !sourceList.contains(entry)) ? sourceList.add(entry) : false;
voidaddDistinctItems(List fromItems, List toItems)
add Distinct Items
for (String fromItem : fromItems) {
    if (!toItems.contains(fromItem)) {
        toItems.add(fromItem);
intaddDistinctList(List sourceList, List entryList)
add Distinct List
if (sourceList == null || isEmpty(entryList)) {
    return 0;
int sourceCount = sourceList.size();
for (V entry : entryList)
    if (!sourceList.contains(entry)) {
        sourceList.add(entry);
return sourceList.size() - sourceCount;
LongaddWithExpDecay(List distinctVals)
add With Exp Decay
Collections.sort(distinctVals, Collections.reverseOrder());
long denom = distinctVals.get(0);
for (int i = 1; i < distinctVals.size(); i++) {
    denom = (long) (denom * Math.pow(distinctVals.get(i), 1.0 / (1 << i)));
return denom;
voidconstructDistinctClause(StringBuffer selectClause, List attributes, boolean isCountOnly)
construct Distinct Clause
String distinctClause;
if (attributes == null || attributes.isEmpty()) {
    distinctClause = DISTINCT.concat(ROOT_OBJ_ALIAS);
} else {
    distinctClause = DISTINCT;
    for (Iterator<String> iterator = attributes.iterator(); iterator.hasNext();) {
        String attr = (String) iterator.next();
        distinctClause = distinctClause.concat(ROOT_OBJ_ALIAS + DOT + attr);
...
Listdistinct(List list)
distinct
int m = 0;
List<String> strList = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
    for (int j = 0; j < list.size(); j++) {
        if (list.get(i).trim().equals(list.get(j).trim())) {
            if (i != j) {
                m = j;
                list.remove(m);
...
Listdistinct(List list)
distinct
return null;
Listdistinct(List vector)
distinct
List<T> distinctVector = new ArrayList<T>();
vector.stream().distinct().forEach(s -> distinctVector.add(s));
return distinctVector;
intdistinctList(List sourceList)
distinct List
if (isEmpty(sourceList)) {
    return 0;
int sourceCount = sourceList.size();
int sourceListSize = sourceList.size();
for (int i = 0; i < sourceListSize; i++)
    for (int j = (i + 1); j < sourceListSize; j++) {
        if (sourceList.get(i).equals(sourceList.get(j))) {
...
String[]getDistinctStrings(String[] list)
this method takes out all of the duplicate strings.
ArrayList distincts = new ArrayList(list.length);
for (int i = 0; i < list.length; i++) {
    if (!distincts.contains(list[i])) {
        distincts.add(list[i]);
return toArray(distincts);