/** * 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); } } }
public static Cons lookupMemoizedValue( MemoizationTable memotable, Stella_Object arg1, Stella_Object arg2, Stella_Object arg3, Stella_Object arg4, int eqvector) { { IntegerHashTable hashtable = memotable.hashTable; Cons timestamp = null; int hashcode = 0; Cons entry = Stella.NIL; Cons bucket = Stella.NIL; if (hashtable == null) { hashtable = IntegerHashTable.newIntegerHashTable(); memotable.hashTable = hashtable; memotable.currentTimestamp = Cons.cons(null, Stella.NIL); } timestamp = memotable.currentTimestamp; hashcode = Stella_Object.hashMemoizedArguments(arg1, arg2, arg3, arg4, eqvector); bucket = ((Cons) (hashtable.lookup(hashcode))); if (bucket != null) { if (((Cons) (bucket.value)) == timestamp) { entry = Cons.findMemoizedValueEntry(bucket, arg1, arg2, arg3, arg4, eqvector, false); if (entry != null) { return (entry); } } else { bucket.value = timestamp; bucket.rest = Stella.NIL; } } entry = Stella_Object.makeMemoizedValueEntry(null, arg1, arg2, arg3, arg4); if (bucket != null) { bucket.rest = Cons.cons(entry, bucket.rest); } else { hashtable.insertAt(hashcode, Cons.cons(timestamp, Cons.cons(entry, Stella.NIL))); } return (entry); } }