public class Environment
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Class of environments for level 1 objects.
An Environment is a set of integer-valued variables and
a set of real-valued variable names.
Level 1 objects (Abstract1
, etc.) refer to variables
by name, and are defined relative to an environment.
In an environment, no two variables can have the same name
(even an integer-valued and a real-valued).
An environment maps level 1 variable names to level 0 dimensions. First, it sorts variables into integer-valued variables first, and real-valued variables next. Each set of variables is further sorted in lexicographic order. Methods to add, remove, or permute variables in environments take care to maintain this order. Changes of environments on level 1 objects automatically apply any needed permutation required to retain consistency with the environment.
Environment objects are immutable.
An Environment object encapsulates an ap_environment_t
Apron object allocated in the C heap.
Constructor and Description |
---|
Environment()
Constructs an empty environment.
|
Environment(java.lang.String[] intVars,
java.lang.String[] realVars) |
Environment(Var[] intVars,
Var[] realVars)
Constructs an environment containing some integer-valued and
some real-valued variables.
|
Modifier and Type | Method and Description |
---|---|
Environment |
add(java.lang.String[] intVars,
java.lang.String[] realVars) |
Environment |
add(Var[] intVars,
Var[] realVars)
Returns a new environment with some integer-valued and/or
real-valued variables added.
|
Environment |
addPerm(java.lang.String[] intVars,
java.lang.String[] realVars,
Dimperm[] p) |
Environment |
addPerm(Var[] intVars,
Var[] realVars,
Dimperm[] p)
Returns a new environment with some integer-valued and/or
real-valued variables added.
|
Environment |
clone()
Returns this (as Environment are immutable).
|
int |
cmp(Environment e)
Returns -2 if the environments are incompatible,
-1 if this is a subset of e,
0 if this and e are equal,
1 if this is a superset of e,
and 2 otherwise, if this and e have a least common element.
|
Dimchange |
dimchange(Environment e)
Returns the dimension specification to add to convert a
level 0 object on the environment this to a level 0 object on
the super-environment e.
|
Dimchange[] |
dimchange2(Environment e)
Returns the dimension specification to add and to remove to
convert a level 0 object on environment this to a level 0 object
on environment e.
|
int |
dimOfVar(java.lang.String var) |
int |
dimOfVar(Var var)
Returns the index associated to the variable in the environment.
|
boolean |
equals(java.lang.Object x)
Whether x is a Generator1 and structurally equal to this.
|
protected void |
finalize()
Deallocates the underlying Apron object.
|
Dimension |
getDimension()
Returns the number of integer-valued and real-valued variables in the
environment.
|
Var[] |
getIntVars()
Returns the set of integer-valued variable names,
ordered in lexical order.
|
Var[] |
getRealVars()
Returns the set of real-valued variable names,
ordered in lexical order.
|
int |
getSize()
Returns the total number of variables in the environment.
|
Var[] |
getVars()
Returns the set of all variables, ordered by dimension.
|
int |
hashCode()
Returns a hash of the environment.
|
boolean |
hasVar(java.lang.String var) |
boolean |
hasVar(Var var)
Whether a variable named var exists in the environment.
|
boolean |
isEqual(Environment e)
Whether this and e are equal.
|
boolean |
isIncluded(Environment e)
Whether this is a subset of e.
|
boolean |
isInt(int dim)
Whether the given dimension is integer-valued.
|
boolean |
isInt(java.lang.String var) |
boolean |
isInt(Var var)
Whether the given variable is integer-valued.
|
Environment |
lce(Environment op)
Returns the least environment extending this and op.
|
static Environment |
lce(Environment[] ar)
Returns the least environment extending all environments in ar.
|
Environment |
remove(java.lang.String[] vars) |
Environment |
remove(Var[] vars)
Returns a new environment with some variables removed.
|
Environment |
rename(java.lang.String[] org,
java.lang.String[] dst) |
Environment |
rename(java.lang.String[] org,
java.lang.String[] dst,
Dimperm[] p) |
Environment |
rename(Var[] org,
Var[] dst)
Returns the environment obtained by mapping each variable
named org[i] to dst[i].
|
Environment |
rename(Var[] org,
Var[] dst,
Dimperm[] p)
Returns the environment obtained by mapping each variable
named org[i] to dst[i].
|
java.lang.String |
toString()
Returns the list of variable names in the environment,
ordered by dimension.
|
Var |
varOfDim(int dim)
Returns the name of the variable at dimension dim.
|
public Environment()
public Environment(java.lang.String[] intVars, java.lang.String[] realVars)
protected void finalize()
finalize
in class java.lang.Object
public Environment add(java.lang.String[] intVars, java.lang.String[] realVars)
public Environment add(Var[] intVars, Var[] realVars)
this is not modified.
One or both array(s) can be null.
Added variables must not already exist.
public Environment addPerm(java.lang.String[] intVars, java.lang.String[] realVars, Dimperm[] p)
public Environment addPerm(Var[] intVars, Var[] realVars, Dimperm[] p)
Similar to add(Var[], Var[])
, but also returns
in p[0] the level 0 dimension permutation induced by the variable
addition in order to keep them sorted.
public Environment remove(java.lang.String[] vars)
public Environment remove(Var[] vars)
this is not modified.
Removed variables must exist in this.
public Environment lce(Environment op)
this and op are not modified.
public static Environment lce(Environment[] ar)
Environments in ar are not modified.
public Environment rename(java.lang.String[] org, java.lang.String[] dst)
public Environment rename(Var[] org, Var[] dst)
org[] and dst[] must have the same size.
public Environment rename(java.lang.String[] org, java.lang.String[] dst, Dimperm[] p)
public Environment rename(Var[] org, Var[] dst, Dimperm[] p)
Similar to rename(Var[], Var[])
, but also returns
in p[0] the level 0 dimension permutation to switch from the original
to the renamed environment.
public Dimension getDimension()
public int getSize()
public boolean hasVar(java.lang.String var)
public boolean hasVar(Var var)
public int dimOfVar(java.lang.String var)
public int dimOfVar(Var var)
Throws an IllegalArgumentException if no such variable exists.
public boolean isInt(java.lang.String var)
public boolean isInt(Var var)
public boolean isInt(int dim)
public Var varOfDim(int dim)
public Var[] getIntVars()
public Var[] getRealVars()
public Var[] getVars()
Integer-valued variables appear first, in lexicographic order, then real-valued variables, also in lexicographic order.
public java.lang.String toString()
toString
in class java.lang.Object
public Dimchange dimchange(Environment e)
e must be a super-environment of this.
public Dimchange[] dimchange2(Environment e)
To convert from a to b, assuming r=a.dimchange2(b)
, you
should first add r[0] dimensions and then remove r[1]
dimensions.
The two environments must not have variables with the same name and different type.
public boolean isEqual(Environment e)
public boolean isIncluded(Environment e)
public int cmp(Environment e)
Note: -2 is returned when there exists a variable that is integer in one environment, and real in the other one.
public int hashCode()
hashCode
in class java.lang.Object
public Environment clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object