Java Two Lists are ignored in order, null is ignored, and duplicates are ignored.

Table of Contents ⇒ Java Algorithm Library-Artery-Sample

Q01_05.java


package jp.avaj.lib.algo;

import java.util.List;

import jp.avaj.lib.def.ArDuplicate;
import jp.avaj.lib.def.ArNull;
import jp.avaj.lib.def.ArSeq;
import jp.avaj.lib.test.L;

/**
 *Equal value judgment is performed by ignoring the order of two Lists, ignoring null, and ignoring duplicates.
 *
 *-Use the following methods of ArList
 *    equals(List<T> list0,List<T> list1,ArSeq arSeq,ArNull arNull,ArDuplicate arDup)
 *
 *・ Ignore order is ArSeq.Specify IGNORE.ArSeq if not ignored.NOT_Specify IGNORE.
 *・ Ignore null is ArNull.Specify IGNORE.ArNull if not ignored.NOT_Specify IGNORE.
 *・ Ignore duplicates is ArDuplicate.Specify IGNORE.ArDuplicate if not ignored.NOT_Specify IGNORE.
 *
 *-In this sample, I specified to ignore separately, but it is OK even if they are mixed.
 */
public class Q01_05 {
  public static void main(String[] args) {
    List<String> list0;
    List<String> list1;

    L.p("Judge by ignoring the order");
    {
       list0 = ArList.construct("aaaa,bbbb,cccc");
       list1 = ArList.construct("bbbb,cccc,aaaa");
       //First, do not ignore
       L.p(ArList.equals(list0,list1,ArSeq.NOT_IGNORE,ArNull.NOT_IGNORE,ArDuplicate.NOT_IGNORE)+"");
       //Ignore and judge.
       L.p(ArList.equals(list0,list1,ArSeq.IGNORE,ArNull.NOT_IGNORE,ArDuplicate.NOT_IGNORE)+"");
    }

    L.p("Judge by ignoring null");
    {
      list0 = ArList.construct(new String[]{"aaaa",null,"bbbb","cccc"});
      list1 = ArList.construct(new String[]{"aaaa","bbbb","cccc",null});
      //First, do not ignore
      L.p(ArList.equals(list0,list1,ArSeq.NOT_IGNORE,ArNull.NOT_IGNORE,ArDuplicate.NOT_IGNORE)+"");
      //Ignore and judge.
      L.p(ArList.equals(list0,list1,ArSeq.NOT_IGNORE,ArNull.IGNORE,ArDuplicate.NOT_IGNORE)+"");
    }

    L.p("Ignore duplication and judge");
    {
      list0 = ArList.construct("aaaa,bbbb,cccc");
      list1 = ArList.construct("aaaa,bbbb,cccc,bbbb");
      //First, do not ignore
      L.p(ArList.equals(list0,list1,ArSeq.NOT_IGNORE,ArNull.NOT_IGNORE,ArDuplicate.NOT_IGNORE)+"");
      //Ignore and judge.
      L.p(ArList.equals(list0,list1,ArSeq.NOT_IGNORE,ArNull.NOT_IGNORE,ArDuplicate.IGNORE)+"");

    }
  }
}

Q01_05.txt


Judge by ignoring the order
false
true
Judge by ignoring null
false
true
Ignore duplication and judge
false
true

Recommended Posts

Java Two Lists are ignored in order, null is ignored, and duplicates are ignored.
StringUtils.isNotBlank is convenient for empty judgment and null judgment in java
Specify the order in which configuration files and classes are loaded in Java
Compare Lists in Java
Same judgment / equal value judgment / comparison / order in Swift and Java
Is short-circuit evaluation really fast? Difference between && and & in Java
[Java] Get the dates of the past Monday and Sunday in order
Encoding and Decoding example in Java
StringBuffer and StringBuilder Class in Java
Understanding equals and hashCode in Java
Hello world in Java and Gradle
[Java] What are overrides and overloads?
Let's think about what declarative programming is in Java and Elm (Part 1)
Review of "strange Java" and Java knowledge that is often forgotten in Java Bronze