lab_hash
Hellish Hash Tables
AnagramFinder< Dict > Class Template Reference

AnagramFinder class. More...

#include "anagram_finder.h"

+ Collaboration diagram for AnagramFinder< Dict >:

Public Member Functions

 AnagramFinder (const std::string &ifilename)
 Constructs an AnagramFinder based on a filename to read potential anagrams from. More...
 
 AnagramFinder (const std::vector< std::string > &istrings)
 Constructs an AnagramFinder based on a set of strings instead of a filename. More...
 
std::vector< std::stringgetAnagrams (const std::string &word)
 Retrieves a set of words that are anagrams of a given word. More...
 
void writeAnagrams (const std::string &word, const std::string &output_file)
 Retrieves a set of anagrams in the finder of a given words, but writes them out to a file instead of returning a vector. More...
 

Private Member Functions

bool checkWord (const std::string &word, const std::string &test)
 Determines if the given word is an anagram of the test word. More...
 

Private Attributes

bool file
 Indicates whether a file was used to build the finder or not. More...
 
std::string filename
 Name of the file to read anagrams from. More...
 
std::vector< std::stringstrings
 Set of strings to find anagrams in. More...
 

Detailed Description

template<template< class K, class V > class Dict>
class AnagramFinder< Dict >

AnagramFinder class.

Provides an interface for finding anagrams in a set of strings or within a file.

Author
Chase Geigle
Date
Spring 2011
Summer 2012

Constructor & Destructor Documentation

◆ AnagramFinder() [1/2]

template<template< class K, class V > class Dict>
AnagramFinder< Dict >::AnagramFinder ( const std::string ifilename)

Constructs an AnagramFinder based on a filename to read potential anagrams from.

Parameters
ifilenameThe name of the file to read in.

◆ AnagramFinder() [2/2]

template<template< class K, class V > class Dict>
AnagramFinder< Dict >::AnagramFinder ( const std::vector< std::string > &  istrings)

Constructs an AnagramFinder based on a set of strings instead of a filename.

Parameters
istringsThe set of strings to use for this finder.

Member Function Documentation

◆ getAnagrams()

template<template< class K, class V > class Dict>
vector< string > AnagramFinder< Dict >::getAnagrams ( const std::string word)

Retrieves a set of words that are anagrams of a given word.

Parameters
wordThe word we wish to find anagrams of inside the finder.

◆ writeAnagrams()

template<template< class K, class V > class Dict>
void AnagramFinder< Dict >::writeAnagrams ( const std::string word,
const std::string output_file 
)

Retrieves a set of anagrams in the finder of a given words, but writes them out to a file instead of returning a vector.

Parameters
wordThe word we wish to find anagrams of inside the finder.
output_fileThe name of the file we want to write to.

◆ checkWord()

template<template< class K, class V > class Dict>
bool AnagramFinder< Dict >::checkWord ( const std::string word,
const std::string test 
)
private

Determines if the given word is an anagram of the test word.

Parameters
wordWord that is possibly an anagram.
testWord to check against.
Returns
A boolean value indicating whether word is an anagram of test.
Todo:
Implement this function! You should use the provided templated hashtable class Dict.

Member Data Documentation

◆ file

template<template< class K, class V > class Dict>
bool AnagramFinder< Dict >::file
private

Indicates whether a file was used to build the finder or not.

◆ filename

template<template< class K, class V > class Dict>
std::string AnagramFinder< Dict >::filename
private

Name of the file to read anagrams from.

Only set if the file-based constructor is used.

◆ strings

template<template< class K, class V > class Dict>
std::vector<std::string> AnagramFinder< Dict >::strings
private

Set of strings to find anagrams in.

Only set if the std::vector constructor is used.


The documentation for this class was generated from the following files: