示例#1
0
  public boolean equals(Object o) {
    if (!(o instanceof FormIndex)) return false;

    FormIndex a = this;
    FormIndex b = (FormIndex) o;

    return (a.compareTo(b) == 0);

    //		//TODO: while(true) loops freak me out, this should probably
    //		//get written more safely. -ctsims
    //
    //		//Iterate over each level of reference, and identify whether
    //		//each object stays in sync
    //		while(true) {
    //			if(index.isTerminal() != local.isTerminal() ||
    //					index.getLocalIndex() != local.getLocalIndex() ||
    //					index.getInstanceIndex() != local.getInstanceIndex()) {
    //				return false;
    //			}
    //			if(index.isTerminal()) {
    //				return true;
    //			}
    //			local = local.getNextLevel();
    //			index = index.getNextLevel();
    //		}
    //
  }
示例#2
0
  // if exact = true: return the index of a value, -1 if not present
  // if exact = false: return the index of the highest value <= the target value, -1 if all values
  // are greater than the target value
  public int indexOf(FormIndex index, boolean exact) {
    int lo = 0;
    int hi = v.size() - 1;

    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      FormIndex val = get(mid);

      if (val.compareTo(index) < 0) {
        lo = mid + 1;
      } else if (val.compareTo(index) > 0) {
        hi = mid - 1;
      } else {
        return mid;
      }
    }

    return exact ? -1 : lo - 1;
  }