SetUtil { public static int calculateNumberOfTotalOrderings(final PartialOrderedSet<?> set) throws InterruptedException { return getAllTotalOrderings(set).size(); } private  SetUtil(); @SafeVarargs static Collection<T> union(final Collection<T>... set); static List<T> union(final List<T>... lists); static Collection<T> symmetricDifference(final Collection<T> a, final Collection<T> b); static Collection<T> getMultiplyContainedItems(final List<T> list); static Collection<S> intersection(final Collection<T> a, final Collection<U> b); static boolean disjoint(final Collection<T> a, final Collection<U> b); static Collection<Collection<T>> getPotenceOfSet(final Collection<T> set, final byte exponent); static Collection<Collection<T>> getCartesianProductOfSetsOfSameClass(final Collection<Collection<T>> items); static Collection<Collection<T>> powerset(final Collection<T> items); static Collection<Collection<T>> getAllPossibleSubsets(final Collection<T> items); static Collection<Set<T>> subsetsOfSize(final Collection<T> set, final int size); static List<Set<T>> getAllPossibleSubsetsWithSizeParallely(final Collection<T> superSet, final int k); static List<Set<T>> getAllPossibleSubsetsWithSize(final Collection<T> superSet, final int k); static Collection<List<T>> getPermutations(final Collection<T> set); static Collection<S> difference(final Collection<T> a, final Collection<U> b); static Collection<S> getDisjointSet(final Collection<T> a, final Collection<U> b); static List<S> difference(final List<T> a, final Collection<U> b); static boolean differenceEmpty(final Collection<T> a, final Collection<U> b); static boolean differenceNotEmpty(final Collection<T> a, final Collection<U> b); static Collection<Pair<S, T>> cartesianProduct(final Collection<S> a, final Collection<T> b); static Collection<List<T>> cartesianProduct(final List<? extends Collection<T>> listOfSets); static Collection<List<S>> cartesianProduct(final Collection<S> set, final int number); static Collection<Pair<K, V>> relation(final Collection<K> keys, final Collection<V> values, final Predicate<Pair<K, V>> relationPredicate); static Map<K, Collection<V>> relationAsFunction(final Collection<K> keys, final Collection<V> values, final Predicate<Pair<K, V>> relationPredicate); static Collection<Map<K, V>> allMappings(final Collection<K> domain, final Collection<V> range, final boolean totalsOnly, final boolean injectivesOnly, final boolean surjectivesOnly); static Collection<Map<K, V>> allTotalMappings(final Collection<K> domain, final Collection<V> range); static Collection<Map<K, V>> allPartialMappings(final Collection<K> domain, final Collection<V> range); static Set<Map<K, V>> allTotalAndInjectiveMappingsWithConstraint(final Collection<K> domain, final Collection<V> range, final Predicate<Map<K, V>> pPredicate); static Set<Map<K, V>> allTotalMappingsWithLocalConstraints(final Collection<K> domain, final Collection<V> range, final Predicate<Pair<K, V>> pPredicate); static Set<Map<K, V>> allFuntionsFromFunctionallyDenotedRelation(final Map<K, Collection<V>> pRelation); static void shuffle(final List<T> list, final long seed); static T getRandomElement(final Collection<T> set, final long seed); static T getRandomElement(final Collection<T> set, final Random random); static Collection<T> getRandomSubset(final Collection<T> set, final int k, final Random random); static Collection<Integer> getRandomSetOfIntegers(final int maxExclusive, final int k, final Random random); static List<T> mergeSort(final Collection<T> set); static List<K> keySetSortedByValues(final Map<K, V> map, final boolean asc); static int calculateNumberOfTotalOrderings(final PartialOrderedSet<?> set); static Collection<List<E>> getAllTotalOrderings(final PartialOrderedSet<E> set); static String serializeAsSet(final Collection<String> set); static Set<String> unserializeSet(final String setDescriptor); static List<String> unserializeList(final String listDescriptor); static Interval unserializeInterval(final String intervalDescriptor); static List<T> getInvertedCopyOfList(final List<T> list); static List<T> addAndGet(final List<T> list, final T item); static Map<U, Collection<T>> groupCollectionByAttribute(final Collection<T> collection, final IGetter<T, U> getter); static List<String> explode(final String stringList); static List<String> explode(final String stringList, final String separator); static String implode(final Collection<? extends Object> collection, final String separator); static boolean doesStringCollectionOnlyContainNumbers(final Collection<String> strings); static Type getGenericClass(final Collection<?> c); static int argmax(final List<T> list); static int argmax(final T[] arr); static int argmin(final List<T> list); static int argmin(final T[] arr); static int argmin(final int[] arr); static int argmax(final int[] arr);  }
@Test public void testcalculateNumberOfTotalOrderings() throws InterruptedException { final String a, b, c, d; a = "a"; b = "b"; c = "c"; d = "d"; final PartialOrderedSet<String> unorderedSet = new PartialOrderedSet<>(); unorderedSet.add(a); unorderedSet.add(b); unorderedSet.add(c); unorderedSet.add(d); assertTrue(SetUtil.calculateNumberOfTotalOrderings(unorderedSet) == 24); final PartialOrderedSet<String> sortedSetA = new PartialOrderedSet<>(); sortedSetA.add(a); sortedSetA.add(b); sortedSetA.add(c); sortedSetA.add(d); sortedSetA.addABeforeB(a, b); sortedSetA.addABeforeB(c, d); assertTrue(SetUtil.calculateNumberOfTotalOrderings(sortedSetA) == 6); final PartialOrderedSet<String> sortedSetB = new PartialOrderedSet<>(); sortedSetB.add(a); sortedSetB.add(b); sortedSetB.add(c); sortedSetB.add(d); sortedSetB.addABeforeB(a, b); sortedSetB.addABeforeB(b, c); assertTrue(SetUtil.calculateNumberOfTotalOrderings(sortedSetB) == 4); }