Word Game Builder 2.0.1f2
Reference Manual
Public Member Functions | Public Attributes | Properties | List of all members
WordSet Class Reference

A specialized data structure for storing letters and words. More...

+ Inheritance diagram for WordSet:
+ Collaboration diagram for WordSet:

Public Member Functions

void CollapseSet ()
 Compress the set into compressed form to save memory. Also clears the runtime set. More...
 
bool Contains (string word)
 Returns true if the word set contains a word. More...
 
int Contains (string prefix, int maxWordLength, int maxIterations, IList< string > stringList)
 Returns the amount of words that starts with the specified prefix. More...
 
void Decompress ()
 Expands the set from compressed form. More...
 
IEnumerator Decompress (System.Action< float > progressCallback, int iterationsPerFrame=100)
 Expands the set from compressed form. Yields when progress is updated and can be used in a coroutine. More...
 
AsyncTask DecompressAsync ()
 Expands the set from compressed form asynchronously. More...
 
AsyncTask DecompressAsync (System.Action callback)
 Expands the set from compressed form asynchronously. More...
 
AsyncTask DecompressAsync (System.Action callback, System.Action< float > progressCallback, int iterationsPerFrame=100)
 Expands the set from compressed form asynchronously. More...
 
WordResult FindWord (string word, bool ordered)
 Finds the word in the set. More...
 
WordResult FindWord (string word, bool ordered, int maxWordLength, int maxIterations)
 Finds the word in the set. More...
 
AsyncTask FindWordAsync (string word, bool ordered, System.Action< WordResult > callback)
 Finds the word in the set, asynchronously. More...
 
AsyncTask FindWordAsync (string word, bool ordered, int maxWordLength, int maxIterations, System.Action< WordResult > callback)
 Finds the word in the set, asynchronously. More...
 
WordResult FindWords (string prefix, int maxWordLength, int maxIterations)
 Returns all words that begin with a prefix, up to maxIterations. Returns Wordresult.empty if no words are found. More...
 
AsyncTask FindWordsAsync (string prefix, int maxWordLength, int maxIterations, System.Action< WordResult > callback)
 Asynchronously returns all words that begin with a prefix, up to maxIterations. More...
 
bool Insert (string word)
 Inserts a word into the set. More...
 
void InsertRange (IEnumerable< string > words)
 Inserts an enumerable of words into the set. More...
 
void Optimize ()
 Optimizes a word set for fast searches. This may take a while and should be done offline - not at runtime. More...
 
bool Remove (string word)
 Removes a word from the set. More...
 

Public Attributes

const int k_MaxPrefixLength
 The maximum length of a prefix in the word set's internal representation. More...
 

Properties

bool isExpanded [get]
 Whether or not the word set is expanded in memory. More...
 
int wordCount [get]
 Gets the amount of words in the word set. More...
 

Detailed Description

A specialized data structure for storing letters and words.

The WordSet is a highly optimized structure for fast word searches. It is loaded in a compressed form, and must be decompressed before lookup operations will work.

Member Function Documentation

void CollapseSet ( )
inline

Compress the set into compressed form to save memory. Also clears the runtime set.

The word set cannot be used in compressed form.

+ Here is the caller graph for this function:

bool Contains ( string  word)
inline

Returns true if the word set contains a word.

Search operations in the word set use the underlying dictionary strings, unlike the WordChecker class (which uses letter tiles).

Parameters
wordThe word to search for.
Returns
true if the word was found, otherwise false.
int Contains ( string  prefix,
int  maxWordLength,
int  maxIterations,
IList< string >  stringList 
)
inline

Returns the amount of words that starts with the specified prefix.

Accepts a pre-allocated list (should be empty) to use for calculations.

Parameters
prefixThe prefix to search for.
maxWordLengthThe maximum allowed word length.
maxIterationsThe maximum amount of iterations to perform.
stringListA scratch list for prefix calculations.
Returns
The amount of words found.

+ Here is the call graph for this function:

void Decompress ( )
inline

Expands the set from compressed form.

If Language.decompressOnLoad is disabled, this must be called explicitly.

+ Here is the caller graph for this function:

IEnumerator Decompress ( System.Action< float >  progressCallback,
int  iterationsPerFrame = 100 
)
inline

Expands the set from compressed form. Yields when progress is updated and can be used in a coroutine.

Parameters
progressCallbackThe method to call each time the task's progress is updated. This method must take a float as the only argument.
iterationsPerFrameThe maximum amount of iterations to process per frame. Defaults to 100.
Returns
An IEnumerator object. This method can be used as a coroutine.

If Language.decompressOnLoad is disabled, this must be called explicitly.

+ Here is the call graph for this function:

AsyncTask DecompressAsync ( )
inline

Expands the set from compressed form asynchronously.

Returns
An object representing an asynchronous task.

If Language.decompressOnLoad is disabled, this must be called explicitly.

AsyncTask DecompressAsync ( System.Action  callback)
inline

Expands the set from compressed form asynchronously.

Returns
An object representing an asynchronous task.
Parameters
callbackThe method to call upon completion.

If Language.decompressOnLoad is disabled, this must be called explicitly.

+ Here is the call graph for this function:

AsyncTask DecompressAsync ( System.Action  callback,
System.Action< float >  progressCallback,
int  iterationsPerFrame = 100 
)
inline

Expands the set from compressed form asynchronously.

Returns
An object representing an asynchronous task.
Parameters
callbackThe method to call upon completion.
progressCallbackThe method to call each time the task's progress is updated. This method must take a float as the only argument.
iterationsPerFrameThe amount of iterations per progress frame.

If Language.decompressOnLoad is disabled, this must be called explicitly.

+ Here is the call graph for this function:

WordResult FindWord ( string  word,
bool  ordered 
)
inline

Finds the word in the set.

Returns
A WordResult representing the results of the lookup operation.
Parameters
wordThe string input for the lookup operation.
orderedIf true, performs a check on the string, in order. If false, performs a permutation check on every combination of the string.

Search operations in the word set use the underlying dictionary strings, unlike the WordChecker class, which uses letter tiles.

WordResult FindWord ( string  word,
bool  ordered,
int  maxWordLength,
int  maxIterations 
)
inline

Finds the word in the set.

Returns
A WordResult representing the results of the lookup operation.
Parameters
wordThe string input for the lookup operation.
orderedIf true, performs a check on the string, in order. If false, performs a permutation check on every combination of the string.
maxWordLengthThe maximum length of a word input. If the input is longer than this value, it will be truncated.
maxIterationsThe maximum amount of iterations for any permutation checks.

Search operations in the word set use the underlying dictionary strings, unlike the WordChecker class, which uses letter tiles.

AsyncTask FindWordAsync ( string  word,
bool  ordered,
System.Action< WordResult callback 
)
inline

Finds the word in the set, asynchronously.

Returns
An Task representing the asynchronous task.
Parameters
wordThe string input for the lookup operation.
orderedIf true, performs a check on the string, in order. If false, performs a permutation check on every combination of the string.
callbackThe method to call upon completion. This method must take a WordResult as the only argument.

Search operations in the word set use the underlying dictionary strings, unlike the WordChecker class, which uses letter tiles.

AsyncTask FindWordAsync ( string  word,
bool  ordered,
int  maxWordLength,
int  maxIterations,
System.Action< WordResult callback 
)
inline

Finds the word in the set, asynchronously.

Returns
An Task representing the asynchronous task.
Parameters
wordThe string input for the lookup operation.
orderedIf true, performs a check on the string, in order. If false, performs a permutation check on every combination of the string.
maxWordLengthThe maximum length of a word input. If the input is longer than this value, it will be truncated.
maxIterationsThe maximum amount of iterations for any permutation checks.
callbackThe method to call upon completion. This method must take a WordResult as the only argument.

Search operations in the word set use the underlying dictionary strings, unlike the WordChecker class, which uses letter tiles.

+ Here is the call graph for this function:

WordResult FindWords ( string  prefix,
int  maxWordLength,
int  maxIterations 
)
inline

Returns all words that begin with a prefix, up to maxIterations. Returns Wordresult.empty if no words are found.

Parameters
prefixThe prefix to search.
maxWordLengthThe maximum allowed word length.
maxIterationsThe maximum amount of iterations allowed.
Returns
A WordResult representing the results of the lookup operation.
AsyncTask FindWordsAsync ( string  prefix,
int  maxWordLength,
int  maxIterations,
System.Action< WordResult callback 
)
inline

Asynchronously returns all words that begin with a prefix, up to maxIterations.

Returns
An Task representing the asynchronous task.
Parameters
prefixThe prefix to search.
maxWordLengthThe maximum allowed word length.
maxIterationsThe maximum amount of iterations allowed.
callbackThe method to call upon completion. This method must take a WordResult as the only argument.

+ Here is the call graph for this function:

bool Insert ( string  word)
inline

Inserts a word into the set.

Parameters
wordThe word to insert into the set.
Returns
true if the operation was successful; otherwise false.
void InsertRange ( IEnumerable< string >  words)
inline

Inserts an enumerable of words into the set.

Parameters
wordsThe words to insert.
void Optimize ( )
inline

Optimizes a word set for fast searches. This may take a while and should be done offline - not at runtime.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Remove ( string  word)
inline

Removes a word from the set.

Parameters
wordThe word to remove.
Returns
true if the operation was successful; otherwise false.

Member Data Documentation

const int k_MaxPrefixLength

The maximum length of a prefix in the word set's internal representation.

This value is implementation-specific and cannot be changed.

Property Documentation

bool isExpanded
get

Whether or not the word set is expanded in memory.

int wordCount
get

Gets the amount of words in the word set.