public class TestDenseFrequencyLibrarySimple { public static void main(String[] args) { FrequencyLibrary lib = new DenseFrequencyLibrary(); lib.add("Row Your Boat", 'R'); lib.add("Row Your Boat", 'G'); lib.add("Row Your Boat", 'M'); lib.add("Row Your Boat", 'L'); lib.add("Twinkle Twinkle", 'T'); lib.add("Twinkle Twinkle", 'H'); lib.add("Twinkle Twinkle", 'U'); lib.add("Twinkle Twinkle", 'S'); lib.add("If You're Happy", 'I'); lib.add("If You're Happy", 'I'); lib.add("If You're Happy", 'I'); lib.add("If You're Happy", 'I'); lib.add("Cheer", 'O'); lib.add("Cheer", 'H'); lib.add("Cheer", 'I'); lib.add("Cheer", 'O'); System.out.println("Size is " + lib.size() + " (should be 4)"); System.out.println("Contains 'Twinkle Twinkle'? " + lib.contains("Twinkle Twinkle") + " (should be true)"); System.out.println("Contains 'Happy Birthday'? " + lib.contains("Happy Birthday") + " (should be false)"); MultiSetOfChar freq = lib.getFrequencies("Row Your Boat"); System.out.println("Number of entries for 'Row Your Boat'? " + freq.getCardinality() + " (should be 4)"); boolean result = lib.remove("Twinkle Twinkle", 'H'); System.out .println("Able to remove element 'H' from 'Twinkle Twinkle'? " + result + " (should be true)"); result = lib.remove("Happy Birthday", 'H'); System.out.println("Able to remove element 'H' from 'Happy Birthday'? " + result + " (should be false)"); System.out .println("Random string (should have approx same number of R/G/M/L):"); for (int i = 0; i < 40; i++) { System.out.print(lib.randomUniformChoose("Row Your Boat")); } System.out.println(); System.out.println("Random string (all should be I):"); for (int i = 0; i < 40; i++) { System.out.print(lib.randomUniformChoose("If You're Happy")); } System.out.println(); System.out.println("Random string (*half* should be O):"); for (int i = 0; i < 40; i++) { System.out.print(lib.randomUniformChoose("Cheer")); } System.out.println(); } }