In the spelling corrector article we read a whole file in memory and hold it’s data in a std::string object, and then we use a std::map to hold ranges of this big string. Those ranges are created by making copies of the string. While this aproach is satisfatory, it can be greatly improved if we can afford holding the file data while std::map is in the scope.
I did a filter_iterator for C++ STL containers which is able to filter container elements based on a predicate, wich I have showed to my friend Thiago Adams. Then he pointed me a CUJ (C/C++ Users Journal) article where Maciej Sobczak introduced the Container View Concept. The main idea behind it is that it is able to move elements without really copying them and being able to integrate multiple container elements in just one view.
Greetings, i wrote a C++ version of the Norvig’s spelling corrector. All theory and other language implementations can be found in his website. Here’s my reduced version with less number of lines, that scored 66 lines of code (Implementation in the same source that the declaration): SpellCorrector in C++. Or just take a look at the complete version: