36 lines
1.9 KiB
Java
36 lines
1.9 KiB
Java
//: generics/WatercolorSets.java
|
|
// ©2015 MindView LLC: see Copyright.txt
|
|
import generics.watercolors.*;
|
|
import java.util.*;
|
|
import static net.mindview.util.Print.*;
|
|
import static net.mindview.util.Sets.*;
|
|
import static generics.watercolors.Watercolors.*;
|
|
|
|
public class WatercolorSets {
|
|
public static void main(String[] args) {
|
|
Set<Watercolors> set1 =
|
|
EnumSet.range(BRILLIANT_RED, VIRIDIAN_HUE);
|
|
Set<Watercolors> set2 =
|
|
EnumSet.range(CERULEAN_BLUE_HUE, BURNT_UMBER);
|
|
print("set1: " + set1);
|
|
print("set2: " + set2);
|
|
print("union(set1, set2): " + union(set1, set2));
|
|
Set<Watercolors> subset = intersection(set1, set2);
|
|
print("intersection(set1, set2): " + subset);
|
|
print("difference(set1, subset): " +
|
|
difference(set1, subset));
|
|
print("difference(set2, subset): " +
|
|
difference(set2, subset));
|
|
print("complement(set1, set2): " +
|
|
complement(set1, set2));
|
|
}
|
|
} /* Output: (Sample)
|
|
set1: [BRILLIANT_RED, CRIMSON, MAGENTA, ROSE_MADDER, VIOLET, CERULEAN_BLUE_HUE, PHTHALO_BLUE, ULTRAMARINE, COBALT_BLUE_HUE, PERMANENT_GREEN, VIRIDIAN_HUE]
|
|
set2: [CERULEAN_BLUE_HUE, PHTHALO_BLUE, ULTRAMARINE, COBALT_BLUE_HUE, PERMANENT_GREEN, VIRIDIAN_HUE, SAP_GREEN, YELLOW_OCHRE, BURNT_SIENNA, RAW_UMBER, BURNT_UMBER]
|
|
union(set1, set2): [SAP_GREEN, ROSE_MADDER, YELLOW_OCHRE, PERMANENT_GREEN, BURNT_UMBER, COBALT_BLUE_HUE, VIOLET, BRILLIANT_RED, RAW_UMBER, ULTRAMARINE, BURNT_SIENNA, CRIMSON, CERULEAN_BLUE_HUE, PHTHALO_BLUE, MAGENTA, VIRIDIAN_HUE]
|
|
intersection(set1, set2): [ULTRAMARINE, PERMANENT_GREEN, COBALT_BLUE_HUE, PHTHALO_BLUE, CERULEAN_BLUE_HUE, VIRIDIAN_HUE]
|
|
difference(set1, subset): [ROSE_MADDER, CRIMSON, VIOLET, MAGENTA, BRILLIANT_RED]
|
|
difference(set2, subset): [RAW_UMBER, SAP_GREEN, YELLOW_OCHRE, BURNT_SIENNA, BURNT_UMBER]
|
|
complement(set1, set2): [SAP_GREEN, ROSE_MADDER, YELLOW_OCHRE, BURNT_UMBER, VIOLET, BRILLIANT_RED, RAW_UMBER, BURNT_SIENNA, CRIMSON, MAGENTA]
|
|
*///:~
|