public class Assigner
extends java.lang.Object
This project was carried out at:
and supported byGenOpt Copyright (c) 1998-2021, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
LS
System dependent line separator
|
| Constructor and Description |
|---|
Assigner() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String[] |
assign(java.lang.String[] keyWords,
java.lang.String[] values)
assigns to all keyWords its value by eliminating all references to a keyword with its value
|
private static void |
checkValidInput(int[][] p)
checks for valid input syntax (cycles and references to itself are not allowed)
|
private static boolean[] |
getAssigned(int[][] p)
gets an array which contains
true at the i-th element if
the 0-th element of the i-th row of p is equal to -1 |
private static int[][] |
getReferences(java.lang.String[] keyWords,
java.lang.String[] values)
gets all references to a
keyWords |
private static boolean |
isAllTrue(boolean[] b)
checks whether all values of
b are true |
private static void |
updateValues(java.lang.String[] keyWords,
java.lang.String[] values,
int[][] p)
updates the values by eliminating the keyWord references
|
public static java.lang.String[] assign(java.lang.String[] keyWords,
java.lang.String[] values)
throws java.lang.IllegalArgumentException,
java.lang.RuntimeException
keyWords - the keyWordsvalues - the values of the keywordsjava.lang.IllegalArgumentExceptionjava.lang.RuntimeExceptionprivate static void checkValidInput(int[][] p)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if variables cannot be assigned or if a reference
to itself occursprivate static void updateValues(java.lang.String[] keyWords,
java.lang.String[] values,
int[][] p)
keyWords - the keyWordsvalues - the values of the keywordsp - NxN array which has a number in each element that points to the keyWord which
is referenced. If there is no reference, then the element is equal to -1private static boolean[] getAssigned(int[][] p)
true at the i-th element if
the 0-th element of the i-th row of p is equal to -1p - NxN array which has a -1 as the first element of the i-th column
if there is no further assignement to the i-th variabletrue at the i-th element if the i-th element
is not refered anywhere, falseotherwiseprivate static boolean isAllTrue(boolean[] b)
b are trueb - the array to be checkedtrue if all elements are true,
false otherwiseprivate static int[][] getReferences(java.lang.String[] keyWords,
java.lang.String[] values)
keyWordskeyWords - the keyWordsvalues - the values of the keywordskeyWords in values