Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 7119f565 authored by PECHOUX Romain's avatar PECHOUX Romain
Browse files

FOTierList extends ArrayList instead of composition

parent 65c06cce
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ class Point {
this.x = x;
this.y = y;
this.getX();
// this.getX();
}
}
......
......@@ -28,8 +28,7 @@ import complexityparser.types.env.TypingEnv;
* Represents the list of admissible first order tiers (FOTier) of an operator, constructor, or method.
* The boolean #primitiveReturnType is true if the return type is a primitive type and false if it is a reference type.
*/
public class FOTierList {
private ArrayList<FOTier> results;
public class FOTierList extends ArrayList<FOTier>{
private int arity;
private boolean primitiveReturnType;
......@@ -39,7 +38,7 @@ public class FOTierList {
* The arity being fixed to -1 indicating that the FOTierList has not been set yet.
*/
public FOTierList(boolean primitiveReturnType) {
results = new ArrayList<>();
super();
arity = -1;
this.primitiveReturnType = primitiveReturnType;
}
......@@ -68,32 +67,33 @@ public class FOTierList {
//from the FOTierList arity then an exception is thrown.
throw new IOException("FOTierList::addObserver input of wrong size expected " + arity + " got " + in.length);
}
results.add(new FOTier(out,env,in));
add(new FOTier(out,env,in));
}
/**
/**
* Removes the FOTier at index i.
* @param i - the index of the FOTier to remove.
*/
public void remove(int i) {
results.remove(i);
}
// public void remove(int i) {
// remove(i);
// }
/**
* @return the number of FOTiers in the FOTierList.
*/
public int size() {
return results.size();
}
// public int size() {
// return results.size();
// }
/**
*
* @param i - the index of the FOTier to get.
* @return the FOTier of index i.
*/
public FOTier get(int i) {
return results.get(i);
}
// public FOTier get(int i) {
// return results.get(i);
// }
/**
*
......@@ -101,7 +101,7 @@ public class FOTierList {
* @return the (first) FOTier matching the given input tiers #in and (NONE, NONE), if no match is found.
*/
public FOTier findRes(Tier... in) {
for(FOTier i : results) {
for(FOTier i : this) {
if(i.contains(in)) {
return i;
}
......@@ -116,7 +116,7 @@ public class FOTierList {
* @return a compatible FOTier marching the input tiers #in and the mask #m, (NONE, NONE) if no match is found.
*/
public FOTier findCompatibleRes(Mask m, Tier... in) {
for(FOTier i : results) {
for(FOTier i : this) {
if(i.isCompatibleWith(m, in)) {
//The array is deep copied to avoid any unwanted side effect
//and to provide another possible returned value
......@@ -135,8 +135,8 @@ public class FOTierList {
* @return an array of FOTiers of the FOTierList compatible with the input parameter.
*/
public FOTier[] findAllCompatibles(Mask m, Tier... in) {
ArrayList<FOTier> res = new ArrayList<>(results.size());
for(FOTier i : results) {
ArrayList<FOTier> res = new ArrayList<>(this.size());
for(FOTier i : this) {
if(i.isCompatibleWith(m, in)) {
res.add(i);
}
......@@ -147,7 +147,7 @@ public class FOTierList {
@Override
public String toString() {
StringBuilder str = new StringBuilder();
for(FOTier i : results) {
for(FOTier i : this) {
str.append("\t");
str.append(i);
str.append(";\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment