cross.math.Combinatorics Maven / Gradle / Ivy
/*
* Cross, common runtime object support system.
* Copyright (C) 2008-2012, The authors of Cross. All rights reserved.
*
* Project website: http://maltcms.sf.net
*
* Cross may be used under the terms of either the
*
* GNU Lesser General Public License (LGPL)
* http://www.gnu.org/licenses/lgpl.html
*
* or the
*
* Eclipse Public License (EPL)
* http://www.eclipse.org/org/documents/epl-v10.php
*
* As a user/recipient of Cross, you may choose which license to receive the code
* under. Certain files or entire directories may not be covered by this
* dual license, but are subject to licenses compatible to both LGPL and EPL.
* License exceptions are explicitly declared in all relevant files or in a
* LICENSE file in the relevant directories.
*
* Cross is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. Please consult the relevant license documentation
* for details.
*/
package cross.math;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* Utility class with methods for combinatorics.
*
* @author Nils Hoffmann
*/
@Slf4j
public final class Combinatorics {
private static double[] faculty = null;
/**
*
* @param lh
* @return
*/
public static String[][] toStringArray(Map> lh) {
String[][] s = new String[lh.size()][];
List keys = new LinkedList<>(lh.keySet());
for (int i = 0; i < s.length; i++) {
List ls = lh.get(keys.get(i));
s[i] = ls.toArray(new String[ls.size()]);
}
return s;
}
/**
*
* @param lh
* @return
*/
public static List