変換といっても縦のものを横にするという種類のもので、こんな感じです。
アルファベットが項目で、数字がIDです。
走らせるとアルファベットからIDを列挙します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
// Equivalence Class Transformation | |
public class ECLAT | |
{ | |
public static void main(String args[]) | |
{ | |
HashMap<Integer, byte[]> hash=new HashMap<>(); | |
hash.put(10,new String("acde").getBytes()); | |
hash.put(20,new String("abe").getBytes()); | |
hash.put(30,new String("bce").getBytes()); | |
Set<Integer> keys=hash.keySet(); | |
TreeSet<Integer> sortedKeys=new TreeSet<>(); | |
TreeSet<Character> itemset=new TreeSet<>(); | |
for(Integer key: keys) | |
{ | |
sortedKeys.add(key); | |
} | |
for(Integer key: sortedKeys) | |
{ | |
System.out.print(key+" | "); | |
byte[] buf=hash.get(key); | |
for(int i=0;i<buf.length;i++) | |
{ | |
itemset.add((char)buf[i]); | |
System.out.print((char)buf[i]); | |
if(i<buf.length-1) | |
System.out.print(","); | |
} | |
System.out.println(); | |
} | |
System.out.println(); | |
for(Character ch: itemset) | |
{ | |
System.out.print(ch+" | "); | |
for(Integer key: sortedKeys) | |
{ | |
byte[] buf=hash.get(key); | |
int i=0; | |
while(buf[i]!=ch && ++i<buf.length){} | |
if(i<buf.length) | |
{ | |
System.out.print(key+", "); | |
} | |
} | |
System.out.println(); | |
} | |
} | |
} |