Class Environment
- All Implemented Interfaces:
Serializable
,Cloneable
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.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty environment.Environment
(Var[] intVars, Var[] realVars) Constructs an environment containing some integer-valued and some real-valued variables.Environment
(String[] intVars, String[] realVars) -
Method Summary
Modifier and TypeMethodDescriptionReturns a new environment with some integer-valued and/or real-valued variables added.Returns a new environment with some integer-valued and/or real-valued variables added.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.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.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
Returns the index associated to the variable in the environment.int
boolean
Whether x is a Generator1 and structurally equal to this.protected void
finalize()
Deallocates the underlying Apron object.Returns the number of integer-valued and real-valued variables in the environment.Var[]
Returns the set of integer-valued variable names, ordered in lexical order.Var[]
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
Whether a variable named var exists in the environment.boolean
boolean
Whether this and e are equal.boolean
Whether this is a subset of e.boolean
isInt
(int dim) Whether the given dimension is integer-valued.boolean
Whether the given variable is integer-valued.boolean
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.Returns a new environment with some variables removed.Returns the environment obtained by mapping each variable named org[i] to dst[i].Returns the environment obtained by mapping each variable named org[i] to dst[i].toString()
Returns the list of variable names in the environment, ordered by dimension.varOfDim
(int dim) Returns the name of the variable at dimension dim.
-
Constructor Details
-
Environment
public Environment()Constructs an empty environment. -
Environment
-
Environment
Constructs an environment containing some integer-valued and some real-valued variables.All variable names must be distinct.
-
-
Method Details
-
finalize
protected void finalize()Deallocates the underlying Apron object. -
add
-
add
Returns a new environment with some integer-valued and/or real-valued variables added.this is not modified.
One or both array(s) can be null.
Added variables must not already exist.
-
addPerm
-
addPerm
Returns a new environment with some integer-valued and/or real-valued variables added.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. -
remove
-
remove
Returns a new environment with some variables removed.this is not modified.
Removed variables must exist in this.
-
lce
Returns the least environment extending this and op.this and op are not modified.
-
lce
Returns the least environment extending all environments in ar.Environments in ar are not modified.
-
rename
-
rename
Returns the environment obtained by mapping each variable named org[i] to dst[i].org[] and dst[] must have the same size.
-
rename
-
rename
Returns the environment obtained by mapping each variable named org[i] to dst[i].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. -
getDimension
Returns the number of integer-valued and real-valued variables in the environment. -
getSize
public int getSize()Returns the total number of variables in the environment. -
hasVar
-
hasVar
Whether a variable named var exists in the environment. -
dimOfVar
-
dimOfVar
Returns the index associated to the variable in the environment.Throws an IllegalArgumentException if no such variable exists.
-
isInt
-
isInt
Whether the given variable is integer-valued. -
isInt
public boolean isInt(int dim) Whether the given dimension is integer-valued. -
varOfDim
Returns the name of the variable at dimension dim. -
getIntVars
Returns the set of integer-valued variable names, ordered in lexical order. -
getRealVars
Returns the set of real-valued variable names, ordered in lexical order. -
getVars
Returns the set of all variables, ordered by dimension.Integer-valued variables appear first, in lexicographic order, then real-valued variables, also in lexicographic order.
-
toString
Returns the list of variable names in the environment, ordered by dimension. -
dimchange
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.e must be a super-environment of this.
-
dimchange2
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.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.
-
isEqual
Whether this and e are equal. -
isIncluded
Whether this is a subset of e. -
cmp
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.Note: -2 is returned when there exists a variable that is integer in one environment, and real in the other one.
-
hashCode
public int hashCode()Returns a hash of the environment. -
clone
Returns this (as Environment are immutable). -
equals
Whether x is a Generator1 and structurally equal to this.
-