コード例 #1
0
  public static StellaHashTable newStellaHashTable() {
    {
      StellaHashTable self = null;

      self = new StellaHashTable();
      self.theStellaHashTable = null;
      self.theHashTable = null;
      self.equalTestP = false;
      self.freeElements = Stella.NULL_INTEGER;
      self.initialSize = 50;
      self.size = Stella.NULL_INTEGER;
      self.initializeHashTable();
      return (self);
    }
  }
コード例 #2
0
  /**
   * Return a copy of the hash table <code>self</code>. The bucket table and buckets are freshly
   * allocated, however, the keys and values of entries are not copied themselves (similar to what
   * we do for lists, etc.).
   *
   * @return StellaHashTable
   */
  public StellaHashTable copy() {
    {
      StellaHashTable self = this;

      {
        int size = self.size;

        {
          StellaHashTable self000 = StellaHashTable.newStellaHashTable();

          self000.size = size;
          self000.initialSize = self.initialSize;
          self000.freeElements = self.freeElements;
          self000.equalTestP = self.equalTestP;
          {
            StellaHashTable copy = self000;
            KvCons[] table = self.theTable;
            KvCons[] tablecopy = table;
            KvCons bucket = null;

            if (table != null) {
              tablecopy = new KvCons[size];
              copy.theTable = tablecopy;
              {
                int i = Stella.NULL_INTEGER;
                int iter000 = 0;
                int upperBound000 = size - 1;

                for (; iter000 <= upperBound000; iter000 = iter000 + 1) {
                  i = iter000;
                  bucket = table[i];
                  if (bucket != null) {
                    tablecopy[i] = KvCons.copyKvConsList(bucket);
                  } else {
                    tablecopy[i] = null;
                  }
                }
              }
            }
            return (copy);
          }
        }
      }
    }
  }
コード例 #3
0
  public static Stella_Object accessStellaHashTableSlotValue(
      StellaHashTable self, Symbol slotname, Stella_Object value, boolean setvalueP) {
    if (slotname == Stella.SYM_STELLA_SIZE) {
      if (setvalueP) {
        self.size = ((IntegerWrapper) (value)).wrapperValue;
      } else {
        value = IntegerWrapper.wrapInteger(self.size);
      }
    } else if (slotname == Stella.SYM_STELLA_INITIAL_SIZE) {
      if (setvalueP) {
        self.initialSize = ((IntegerWrapper) (value)).wrapperValue;
      } else {
        value = IntegerWrapper.wrapInteger(self.initialSize);
      }
    } else if (slotname == Stella.SYM_STELLA_FREE_ELEMENTS) {
      if (setvalueP) {
        self.freeElements = ((IntegerWrapper) (value)).wrapperValue;
      } else {
        value = IntegerWrapper.wrapInteger(self.freeElements);
      }
    } else if (slotname == Stella.SYM_STELLA_EQUAL_TESTp) {
      if (setvalueP) {
        self.equalTestP = BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper) (value)));
      } else {
        value = (self.equalTestP ? Stella.TRUE_WRAPPER : Stella.FALSE_WRAPPER);
      }
    } else {
      {
        OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

        stream000.nativeStream.print("`" + slotname + "' is not a valid case option");
        throw ((StellaException)
            (StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
      }
    }
    return (value);
  }