# - - - W o r d B a n k . a d d W o r d
def addWord ( self, rawWord ):
'''Add a word to the bank.
'''
When a word is added, we must perform several operations:
Compute the running maximum word length, self.maxLen.
Add one to the word count, self.__nWords.
Add the word to the set of words in self.__lenMap[, where N]
is the length of the new word.
N
#-- 1 --
# [ word := a Word instance made from rawWord ]
word = Word ( rawWord )
#-- 2 --
# [ self.maxLen := max ( self.maxLen, len(word) )
# self.__nWords +:= 1
# self.__lenMap[len(word)] +:= word ]
self.maxLen = max ( self.maxLen, len(word) )
self.__nWords += 1
if word in self.__lenMap[len(word)]:
raise SyntaxError ( "Duplicate word '%s'." % word )
self.__lenMap[len(word)].add ( word )