Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!ucbvax!pasteur!agate!shelby!daemon From: lane@sumex-aim.stanford.edu (Christopher Lane) Newsgroups: comp.sys.next Subject: HashFile Object Class Message-ID: <2277@shelby.Stanford.EDU> Date: 8 Aug 90 16:20:18 GMT Sender: daemon@shelby.Stanford.EDU Lines: 43 I've FTP'd the file HashFile.tar.Z to the 'submissions' directory (should eventually show up on 'classes' or 'sources') of the cs.orst.edu archive. HashFile is a sub-class of HashTable. (The initial part of) Its 'CLASS DESCRIPTION' from HashFile.wn: HashFile implements a bridge between the hashed database library functions, db(3) (used to implement the 'defaults' database and Digital Librarian index files), and the HashTable object. It can be viewed as an alternate interface to the database library functions or as a type of HashTable that survives program execution. Except for initial object creation, methods are a superset of those provided by HashTable and a HashFile can be substituted for a HashTable in most code. In order to maintain this similarity, the database file is closed when the free method is called on the HashFile object, rather than having a separate method. Database files created using the HashFile object can be manipulated using the utilities dbCatenate, dbCompare, dbDescribe etc. on /usr/lib/database (see dbCatenate(1)). The HashFile object uses a HashTable object as a buffer to optimize multiple access to keys/values. ... The tar file also includes an example program that accesses a database file (the bulk of the tar file) via the HashFile object. This program reads up to 7-digit telephone numbers and searches for them in a database, printing the equivalent words (from the /usr/dict/web2 file) that can be dialed instead: > echo '2277666 227 7666' | HashExample PhoneWords 2277666 barroom bassoon cassoon 227 bap bar bas cap car 7666 Pomo poon room roon soon Of the over 2 million possible seven (or less) digit numbers, less than 2% have matches in PhoneWords, so you'll have to try a lot of numbers before you get one. (Of those that do have a match, over 15% have multiple matches). Comments, suggestions and bug reports on HashFile and HashExample welcome. - Christopher -------