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