import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.Scanner; import java.util.Set; public class SortingClient { public static final int SIZE = 50; public static final int MAX = 10000; public static void main(String[] args) throws FileNotFoundException { List intList = makeIntList(SIZE); SortingAlgorithms.mergesort(intList); System.out.println(intList); /* List strList = makeStringList(SIZE); SortingAlgorithms.selectionsort(intList); */ } public static List makeIntList(int size) { Random random = new Random(42); Set set = new HashSet(); while (set.size() < size) { set.add(random.nextInt(MAX)); } return new ArrayList(set); } public static List makeStringList(int size) throws FileNotFoundException { Random random = new Random(42); Set set = new HashSet(); Scanner scan = new Scanner(new File("10000.txt")); while (scan.hasNext() && set.size() < size) { String word = scan.next().toLowerCase(); if (!word.startsWith("z") && !word.startsWith("y") && !word.startsWith("x") && random.nextInt(5) > 1) { set.add(word); } } scan.close(); return new ArrayList(set); } }