Advertisement

STL?

Started by June 19, 2002 11:35 AM
8 comments, last by jar 22 years, 2 months ago
i was thinking of buying "Accelerated C++" but people say it teaches STL. what is STL? would it be beneficial for game programming?
clicky
Advertisement
what do you mean "but it teachs STL" that''s great!!!!! buy that book right now, or you can live in ignorance and sorrow, whatever floats your boat.
The STL is a powerful library, based upon four simple concepts :

- containers, holding your data (dynamic arrays, linked lists, associative arrays...).
- iterators, giving pointer-like access to the data regardless of the nature of the container (and also to IO streams...)
- algorithms, performing various operations on elemnent ranges defined by pair of iterators (e.g. sort(c.begin(), c.end()) will sort all the elements of container c)
- function objects, letting you plug your own functions inside the algorithms'' loops (e.g. change the comparison function in sort above)

Since it uses templates (the T in STL), you can apply the principle ''if it looks like an X, it is an X'' and provide your own extensions, just by providing the same operations, say, iterators are supposed to provide, without having to worry about the actual type (no need for inheritance) of the object you''re creating.

In short, the STL is very nice. Don''t be afraid of learning it.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote: Original post by Fruny
The STL is a powerful library, based upon four simple concepts :

- containers, holding your data (dynamic arrays, linked lists, associative arrays...).
- iterators, giving pointer-like access to the data regardless of the nature of the container (and also to IO streams...)
- algorithms, performing various operations on elemnent ranges defined by pair of iterators (e.g. sort(c.begin(), c.end()) will sort all the elements of container c)
- function objects, letting you plug your own functions inside the algorithms'' loops (e.g. change the comparison function in sort above)

Since it uses templates (the T in STL), you can apply the principle ''if it looks like an X, it is an X'' and provide your own extensions, just by providing the same operations, say, iterators are supposed to provide, without having to worry about the actual type (no need for inheritance) of the object you''re creating.

In short, the STL is very nice. Don''t be afraid of learning it.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


I couldn''t agree more dude... and to clarify things up for JAR, instead of using char *foo, you can use string foo which is almost the same but you can use foo += ''a'' and it will add the character ''a'' to the string( withouth the '', of course )...

I can''t believe I''ve just started using it. I should''ve found out about this sooner. It, sort of, simplifies coding.

"DaHjajmajQa''jajHeghmeH!"

Cyberdrek
danielc@iquebec.com
Founder
Laval Linux

/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash
[Cyberdrek | ]
Thanks alot for your posts! i just wasn''t really sure what the STL was. you''ve all convinced me to start learning the STL and i also plan on looking at "Accelerated C++"!!!
Advertisement
I own a copy of "Accelerated C++" and can wholeheartedly recommend it. It''s one of the top 3 C++ books (the other two being "The C++ Programming Languag" and "C++ Primer")

A year spent in artificial intelligence is enough to make one believe in God.
"We confess our little faults to persuade people that we have no large ones." -Francois de La Rochefoucauld (1613 - 1680). | My blog
STL rocks. When I got my degree there was no STL. If you wanted a stack, linked list or hash table you had to code it yourself. With STL you can instantly create efficient, bug free data structures. The syntax is scary looking, but don''t let it intimidate you. STL is real easy to learn.

#include <vector>

typedef vector IntVector;
IntVector v;

That all you need to do to create a dynamic array that supports insertion, deletion, sorting, push, pop ... just about any opertation you can image.

The only tricky part is choosing the best container for the job. For instance vectors allows for fast indexing but list are much more efficient when you need to insert items into the middle of a sequence.



quote: Original post by Fruny
The STL is a powerful library, based upon four simple concepts :

- containers, holding your data (dynamic arrays, linked lists, associative arrays...).
- iterators, giving pointer-like access to the data regardless of the nature of the container (and also to IO streams...)
- algorithms, performing various operations on elemnent ranges defined by pair of iterators (e.g. sort(c.begin(), c.end()) will sort all the elements of container c)

Ya know, the first proposed name for the STL was CIA. For some reason, the name didnt stick ;-)

--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote: Original post by Arild Fines
---
The STL is a powerful library, based upon four simple concepts :

- c ontainers, holding your data (dynamic arrays, linked lists, associative arrays...).
- i terators, giving pointer-like access to the data regardless of the nature of the container (and also to IO streams...)
- a lgorithms, performing various operations on elemnent ranges defined by pair of iterators (e.g. sort(c.begin(), c.end()) will sort all the elements of container c)
---
Ya know, the first proposed name for the STL was CIA. For some reason, the name didnt stick ;-)



ROFL

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement