示例#1
0
  /**
   * Return TRUE if <code>x</code> and <code>y</code> represent the same set of key/value pairs.
   *
   * @param y
   * @return boolean
   */
  public boolean objectEqualP(Stella_Object y) {
    {
      StellaHashTable x = this;

      if (Surrogate.subtypeOfP(
          Stella_Object.safePrimaryType(y), Stella.SGT_STELLA_STELLA_HASH_TABLE)) {
        {
          StellaHashTable y000 = ((StellaHashTable) (y));

          if (x.length() == y000.length()) {
            {
              Stella_Object key = null;
              Stella_Object value = null;
              StellaHashTableIterator iter000 = ((StellaHashTableIterator) (x.allocateIterator()));

              while (iter000.nextP()) {
                key = iter000.key;
                value = iter000.value;
                if (!Stella_Object.equalP(value, y000.lookup(key))) {
                  return (false);
                }
              }
            }
            return (true);
          }
        }
      } else {
      }
      return (false);
    }
  }
示例#2
0
  /**
   * Collect all entries of <code>self</code> into a cons list of <code>_LkeyGLvalueG_</code> pairs
   * and return the result.
   *
   * @return Cons
   */
  public Cons consify() {
    {
      StellaHashTable self = this;

      {
        Cons result = Stella.NIL;

        {
          Stella_Object key = null;
          Stella_Object value = null;
          StellaHashTableIterator iter000 = ((StellaHashTableIterator) (self.allocateIterator()));
          Cons collect000 = null;

          while (iter000.nextP()) {
            key = iter000.key;
            value = iter000.value;
            if (collect000 == null) {
              {
                collect000 =
                    Stella_Object.cons(
                        Stella_Object.cons(key, Stella_Object.cons(value, Stella.NIL)), Stella.NIL);
                if (result == Stella.NIL) {
                  result = collect000;
                } else {
                  Cons.addConsToEndOfConsList(result, collect000);
                }
              }
            } else {
              {
                collect000.rest =
                    Stella_Object.cons(
                        Stella_Object.cons(key, Stella_Object.cons(value, Stella.NIL)), Stella.NIL);
                collect000 = collect000.rest;
              }
            }
          }
        }
        return (result);
      }
    }
  }
示例#3
0
  /**
   * Return an <code>equalP</code> hash code for <code>self</code>. Note that this is O(N) in the
   * number of entries of <code>self</code>.
   *
   * @return int
   */
  public int equalHashCode() {
    {
      StellaHashTable self = this;

      {
        int code = 36273463;

        {
          Stella_Object key = null;
          Stella_Object value = null;
          StellaHashTableIterator iter000 = ((StellaHashTableIterator) (self.allocateIterator()));

          while (iter000.nextP()) {
            key = iter000.key;
            value = iter000.value;
            code = (code ^ (key.equalHashCode()));
            code = (code ^ (value.equalHashCode()));
          }
        }
        return (code);
      }
    }
  }