View RSS Feed

ZekeDragon

About "On Learning the STL" Series

Rate this Entry
by , 08-11-2009 at 02:25 AM (567 Views)
The STL is an extremely powerful bunch of software, which can greatly decrease the amount of time needed to program. Unfortunately, I see a lot where people could have very easily used STL containers or algorithms, and instead they code their own solution. To me, it really only reflects one thing, and that's that people don't know everything available in the STL. Maybe because it's "standard" people feel it's not good enough for their needs, I don't know... either way it happens a lot.

Due to this, I wanted to increase awareness of what the STL has to offer, and I have started a massive tutorial series on everything the STL has to offer. I realize that there's a lot to cover, in fact, just covering Vectors has thus far proven to be more than could be packed into two lessons alone. There's more to do with Iterators, and then all the functions Vectors have to assist in coding. And that's just Vectors! There's still Deques, Sets, Maps, Lists, Bitsets, and the Container Adopters to cover, then the whole STL algorithms set that allow for all sorts or mix/matching with containers, generic iterator definitions, and I plan on tacking on a few other non-STL components to this to make it fully inclusive, such as new_handlers, strings, cin and cout (along with istream and ostream_iterators), pairs, etc.

I mean... there's literally enough for me to cover to write a book on the subject. And I plan on doing all of it here.

It's going to work out like this:
Chapter 1: Vectors
Chapter 2: Deques
Chapter 3: Maps and Multimaps
Chapter 4: Sets and Multisets
Chapter 5: Lists
Chapter 6: Bitsets
Chapter 7: Container Adopters
(such as Stacks and Queues)
Chapter 8: Algorithms (This one's gonna be BIG)
Non-STL 1: Strings
Non-STL 2: IOstreams
Non-STL 3: Etc.
Chapter 9: Conclusion/Additions


I have to know if it's okay by the administration for me to edit the earlier entries. I've been thinking about it for a while and I'd like to provide some visual aids, like images and videos, for this. Maybe I can put the preferred lesson as an attachment in a .zip file with .odt files and .ogv videos. Who knows. I honestly don't plan on getting +rep for each part of a chapter, that's not my motivation behind this. I'm in it because I want people to get the most out of the STL!

- Zeke

Submit "About "On Learning the STL" Series" to Digg Submit "About "On Learning the STL" Series" to del.icio.us Submit "About "On Learning the STL" Series" to StumbleUpon Submit "About "On Learning the STL" Series" to Google

Tags: None Add / Edit Tags
Categories
Programming

Comments

  1. Turk4n's Avatar
    Good, that you have goals and pointing out them, are you going to begin today or already have done that?
  2. MathX's Avatar
    Looking forward to reading it.

    Nice read (as Jordan would say)
  3. Jordan's Avatar
    Nice read!
    I've read your tutorial on vectors and it was great. I look forward to the others and yes, feel free to edit your tutorials/posts.
  4. WingedPanther's Avatar
    Feel free to edit them. You get +rep for each one because it IS a service to the community. If you look at the different admins/mods, you can see that we value different kinds of posts. I tend to heavily favor tutorials, for example. Just keep it up. I have a book on STL, I know what a challenge you've set for yourself.
  5. chili5's Avatar
    Great, I'm really looking forward to the tutorials. Are you learning from a book? If yes, what book? Also winged, what book do you have?

    I'm borrowing a book on STL but I want to get my own.

    Just quick regarding the algorithms chapter, what do you mean exactly? Is the things like analysis or something? I know there is an algorithms header but what is it for?
  6. ZekeDragon's Avatar
    @chili5:
    The STL algorithms are mostly a set of algorithms for STL container manipulation. They're used to analyze, sort, organize, and all around change or identify various objects within the STL containers. A great example that is used sparingly is partition, where you can separate elements in a container based on a boolean function of your design. Here's an example (it's sloppy to save space):
    Code:
    #include <iostream>
    #include <vector>
    #include <algorithm>
    
    bool IsMult3(int i) { return (i % 3)==0; }
    
    int main()
    {
        std::vector<int> aVector;
        std::vector<int>::iterator middle, it;
        for (int iii = 1; iii < 11; ++iii) { aVector.push_back(iii); }
        middle = partition (aVector.begin(), aVector.end(), IsMult3);
        std::cout << "Multiples of 3:";
        for (it = aVector.begin(); it < middle; ++it) {
            std::cout << " " << *it;
        }
        return 0;
    }
    They won't be sorted (that's what sort is for!) but they'll be multiples of 3.
    Updated 08-11-2009 at 04:26 PM by ZekeDragon (SPACE shouldn't make "post now" work, especially when TAB goes to "post now". >_<)
  7. vachovsky's Avatar
    I live in Russia, and my english is poor but when i translated C++ Style Guide I remarked for myself that name of variable must be understandable. For example:

    Code:
    std::string file_name = "input.txt";
    // more clearly than 
    
    std::string s = "input.txt"
    
    for (int iii = 1; iii < 11; ++iii) { aVector.push_back(iii); }
    
    // I think, that if change name iii to i  then this code will be more clear... )
    
    for ( int i = 0;  i  < 11; i++ ) 
    {
    aVector.push_back( i );
    }