mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
0e9661aa19
Hungarian is unique (so far) in having two-letter tiles that can be spelled with one-letter tiles AND in allowing words to be spelled both ways. This crashed search based on strings because there were duplicates. So now search is done by tile arrays. Strings are first converted, and then IFF there is more than one tile array result AND the wordlist has the new flag indicating that duplicates are possible, THEN the user is asked to choose among the possible tile spellings of the search string.
86 lines
2.6 KiB
C
86 lines
2.6 KiB
C
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */
|
|
/*
|
|
* Copyright 1997 - 2011 by Eric House (xwords@eehouse.org). All rights
|
|
* reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#ifndef __DICTITER_H__
|
|
#define __DICTITER_H__
|
|
|
|
#ifdef XWFEATURE_WALKDICT
|
|
|
|
#include "comtypes.h"
|
|
|
|
#include "dawg.h"
|
|
#include "model.h"
|
|
#include "mempool.h"
|
|
|
|
#ifdef CPLUS
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define MAX_COLS_DICT 15
|
|
|
|
/* API for iterating over a dict */
|
|
typedef XP_S32 DictPosition;
|
|
typedef struct _DictIter {
|
|
XP_U16 nEdges;
|
|
array_edge* edges[MAX_COLS_DICT];
|
|
#ifdef XWFEATURE_WALKDICT_FILTER
|
|
XP_U16 min;
|
|
XP_U16 max;
|
|
#endif
|
|
#ifdef DEBUG
|
|
XP_U32 guard;
|
|
#endif
|
|
const DictionaryCtxt* dict;
|
|
XP_U32 nWords;
|
|
|
|
DictPosition position;
|
|
} DictIter;
|
|
|
|
typedef struct _IndexData {
|
|
DictPosition* indices;
|
|
Tile* prefixes;
|
|
XP_U16 count; /* in-out: must indicate others are large enough */
|
|
} IndexData;
|
|
|
|
typedef struct _LengthsArray {
|
|
XP_U32 lens[MAX_COLS_DICT+1];
|
|
} LengthsArray;
|
|
|
|
void di_initIter( DictIter* iter, const DictionaryCtxt* dict,
|
|
XP_U16 min, XP_U16 max );
|
|
XP_U32 di_countWords( const DictIter* iter, LengthsArray* lens );
|
|
void di_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data );
|
|
XP_Bool di_firstWord( DictIter* iter );
|
|
XP_Bool di_lastWord( DictIter* iter );
|
|
XP_Bool di_getNextWord( DictIter* iter );
|
|
XP_Bool di_getPrevWord( DictIter* iter );
|
|
XP_Bool di_getNthWord( DictIter* iter, DictPosition position, XP_U16 depth,
|
|
const IndexData* data );
|
|
void di_wordToString( const DictIter* iter, XP_UCHAR* buf, XP_U16 buflen,
|
|
const XP_UCHAR* delim );
|
|
XP_S16 di_findStartsWith( DictIter* iter, const Tile* prefix, XP_U16 nTiles );
|
|
void di_stringToTiles( const XP_UCHAR* str, Tile out[], XP_U16* nTiles );
|
|
DictPosition di_getPosition( const DictIter* iter );
|
|
#ifdef CPLUS
|
|
}
|
|
#endif
|
|
|
|
#endif /* XWFEATURE_WALKDICT */
|
|
#endif
|