Changeset 3638


Ignore:
Timestamp:
09/09/03 23:17:27 (20 years ago)
Author:
piso
Message:

HASH-TABLE-ENTRIES

Location:
trunk/j/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Autoload.java

    r3611 r3638  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: Autoload.java,v 1.51 2003-09-08 02:25:23 piso Exp $
     5 * $Id: Autoload.java,v 1.52 2003-09-09 23:17:27 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    228228        autoload(PACKAGE_SYS, "%structure-set-2", "StructureObject");
    229229        autoload(PACKAGE_SYS, "%time", "Time");
     230        autoload(PACKAGE_SYS, "hash-table-entries", "HashTable");
    230231        autoload(PACKAGE_SYS, "make-fill-pointer-output-stream", "FillPointerOutputStream");
    231232        autoload(PACKAGE_SYS, "puthash", "HashTable");
  • trunk/j/src/org/armedbear/lisp/HashTable.java

    r3519 r3638  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: HashTable.java,v 1.15 2003-08-25 19:15:29 piso Exp $
     5 * $Id: HashTable.java,v 1.16 2003-09-09 23:16:37 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    4444
    4545    private HashTable(LispObject test, int size, LispObject rehashSize,
    46         LispObject rehashThreshold) throws LispError
     46                      LispObject rehashThreshold)
     47        throws LispError
    4748    {
    4849        if (test == NIL || test == Symbol.EQ.getSymbolFunction())
     
    6364    // gethash key hash-table &optional default => value, present-p
    6465    public synchronized LispObject gethash(LispObject key,
    65         LispObject defaultValue) throws LispError
     66                                           LispObject defaultValue)
     67        throws LispError
    6668    {
    6769        LispObject[] values = new LispObject[2];
     
    226228    }
    227229
     230    // Returns a list of (key . value) pairs.
     231    private LispObject ENTRIES()
     232    {
     233        LispObject list = NIL;
     234        for (int i = buckets.length; i-- > 0;) {
     235            HashEntry e = buckets[i];
     236            while (e != null) {
     237                list = new Cons(new Cons(e.key, e.value), list);
     238                e = e.next;
     239            }
     240        }
     241        return list;
     242    }
     243
    228244    private static class HashEntry
    229245    {
     
    269285                return ht.gethash(key, defaultValue);
    270286            }
    271             throw new TypeError(args[1], "hash table");
     287            throw new TypeError(args[1], "hash-table");
    272288        }
    273289    };
     
    294310                return ht.puthash(key, value);
    295311            }
    296             throw new TypeError(args[1], "hash table");
     312            throw new TypeError(args[1], "hash-table");
    297313        }
    298314    };
     
    308324                return ht.remhash(key);
    309325            }
    310             throw new TypeError(second, "hash table");
     326            throw new TypeError(second, "hash-table");
    311327        }
    312328    };
     
    329345        }
    330346    };
     347
     348    // ### hash-table-entries
     349    private static final Primitive1 HASH_TABLE_ENTRIES =
     350        new Primitive1("hash-table-entries", PACKAGE_SYS, false) {
     351        public LispObject execute(LispObject arg) throws LispError
     352        {
     353            if (arg instanceof HashTable)
     354                return ((HashTable)arg).ENTRIES();
     355            throw new TypeError(arg, "hash-table");
     356        }
     357    };
    331358}
Note: See TracChangeset for help on using the changeset viewer.