Ejemplo n.º 1
0
 /**
  * Returns an array of the keys of all the values that are equal to the value specified
  *
  * @param value
  * @return
  */
 public CArray indexesOf(Construct value) {
   CArray ret = new CArray(Target.UNKNOWN);
   if (associative_mode) {
     for (String key : associative_array.keySet()) {
       if (BasicLogic.equals.doEquals(associative_array.get(key), value)) {
         ret.push(new CString(key, Target.UNKNOWN));
       }
     }
   } else {
     for (int i = 0; i < array.size(); i++) {
       if (BasicLogic.equals.doEquals(array.get(i), value)) {
         ret.push(new CInt(i, Target.UNKNOWN));
       }
     }
   }
   return ret;
 }
Ejemplo n.º 2
0
 /**
  * This must be called every time the underlying model is changed, which sets the toString value
  * to dirty, which means that the value will be regenerated next time it is requested.
  */
 private void regenValue(Set<CArray> arrays) {
   if (arrays.contains(this)) {
     return; // Recursive, so don't continue.
   }
   arrays.add(this);
   valueDirty = true;
   if (parent != null) {
     parent.regenValue(arrays);
   }
 }
Ejemplo n.º 3
0
 @Override
 public CArray clone() {
   CArray clone;
   try {
     clone = (CArray) super.clone();
   } catch (CloneNotSupportedException ex) {
     throw new RuntimeException(ex);
   }
   clone.associative_mode = associative_mode;
   if (!associative_mode) {
     if (array != null) {
       clone.array = new ArrayList<Construct>(this.array);
     }
   } else {
     if (associative_array != null) {
       clone.associative_array = new TreeMap<String, Construct>(this.associative_array);
     }
   }
   clone.regenValue(new HashSet<CArray>());
   return clone;
 }