MCPcopy Create free account
hub / github.com/cinder/Cinder / getDescendants

Method getDescendants

samples/_timeline/VisualDictionary/src/Dictionary.cpp:41–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39};
40
41vector<string> Dictionary::getDescendants( const string &word ) const
42{
43 vector<string> result;
44 set<char> foundLetters;
45
46 // we want to figure out what letters follow 'word'
47 // so for "victor" we want 'i' (victories), 's' (victors), 'y' (victory)
48 pair<vector<string>::const_iterator, vector<string>::const_iterator> range;
49 range = std::equal_range( mWords.begin(), mWords.end(), word, CompareStringPrefix( word.size() ) );
50
51 // iterate all the words in our range, and add their last letter to our set of 'foundLetters'
52 for( vector<string>::const_iterator wordIt = range.first; wordIt != range.second; ++wordIt ) {
53 if( wordIt->size() > word.size() )
54 foundLetters.insert( (*wordIt)[word.size()] );
55 }
56
57 // now iterate all the foundLetters; each result word will be 'word' + foundLetter
58 // ex: victor + i (victories)
59 for( set<char>::const_iterator letIt = foundLetters.begin(); letIt != foundLetters.end(); ++letIt )
60 result.push_back( word + *letIt );
61
62 return result;
63}
64
65bool Dictionary::isCompleteWord( const std::string &word ) const
66{

Callers 1

selectNodeMethod · 0.80

Calls 6

CompareStringPrefixClass · 0.85
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected