ftp.nice.ch/pub/next/developer/objc/appkit/Crossword.1.1.NIHS.bs.tar.gz#/Crossword.1.1.NIHS.bs/Source/Dictionary.h

This is Dictionary.h in view mode; [Download] [Up]

/*

File Dictionary.h

A dictionary is responsible for finding words that match a prespecified pattern.  Each dictionary is tied to a .xdict file that contains both words and index information.  The index allows fast retrieval of words that have a specific letter pattern: for example, all five letter words that have a "c" in the third position.

The index is embedded as links in the word lists.  Each word that matches a pattern is followed by a link to the next word that matches that same pattern.  Here is an example entry for the word "hound":

	hound	30  72  -1  146  15

The next word with pattern "h-----" is #30, the next one with pattern "-o----" is #72, etc.  The -1 in the third position indicates that "hound" is the last word that matches "--u--."  An index table stores the first word in the list that matches each pattern, as well as giving the total number of words that match it.

*/

#import "Notifier.h"
#import "FunctionCache.h"


/* ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ  */


#define DEFAULTDICTIONARY		"/default.xdict"

#define LETTERS			26
#define LAST			-1				//	Ð end of list mark
#define MINLETTERS		3
#define MAXLETTERS		21				//	Ð range of word lengths

#define WILDCARD		'?'
#define WORD(p,i)		* (int *) [(p)  elementAt: (i)]


/* ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ  */


typedef struct {
					int		first;
					int		n;
	} linkHead;


typedef struct {
					int			n;
					long		words;
					linkHead	linkTable [LETTERS][MAXLETTERS];
	} indexEntry;


typedef indexEntry		wordIndex [MAXLETTERS + 1];


/* ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ  */


@interface Dictionary:Notifier
{
	FunctionCache	* cache;
	NXStream		* file;
	wordIndex		index;
}

- init;
- (wordIndex *) getIndex;
- free;
- create: sender;
- use: sender;
- useDictionary: (const char *) filename;
- find: (char *) pattern;
- find: (char *) pattern  changeAt: (int) i;
- findWithoutCache: (char *) pattern;
- limit: (id) match  toLetter: (char) c  at: (int) i  forLength: (int) n;
- read: (char *) string  word: (int) i  forLength: (int) n;

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.