+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: On Learning the STL: Chapter 1 (Vectors) - Part 1

  1. #11
    outsid3r's Avatar
    outsid3r is offline Programming God
    Join Date
    Jul 2008
    Posts
    621
    Rep Power
    19

    Re: On Learning the STL: Chapter 1 (Vectors) - Part 1

    STL containers are neat, but you had just missed the most important part. It's a lot easy to make insertion or removal operations towards a STL container, the main point is, when and what containers should we use for a specific situation. Vector can be really very inefficient then you use it to make a lot of insertion operations, because then capacity is full, the vector allocates an entire new space of the space required, also, it copies the last block of space to the new, and finally it deletes the old block of space. You also should explicitly reserve a space after the vector declaration with vector::reserve with the appropriate space you need.
    For insertion operations is much better to use a std::list, which perform insertion operations very efficiently without need to resize, because std::list is a linked list, so just creates a new node and link's it to the last. The main drawback of the std::list is the access time to an element and the extra space required to maintain a double-linked list, std::vector has this advantage over std::list because the access time is fast as an built-in array because it's allocated like an array.
    Maybe i should make a tutorial about this important subject.


    Edit: I didn't have seen part 2 then i was writing this, you specified std::reserve and other important subjects. So you already know part of what i'm talking about.
    Last edited by outsid3r; 08-30-2009 at 04:28 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    Join Date
    Jul 2009
    Location
    Santa Clarita, CA
    Posts
    2,111
    Blog Entries
    47
    Rep Power
    31

    Re: On Learning the STL: Chapter 1 (Vectors) - Part 1

    Yeah, I'm actually not done with this as much as I have stopped working on it. There's at least two more parts to Vectors, and then a lot more, including lists. My very first blog entry outlines how I'll be going about teaching everything in the STL, and lists are on chapter 5. I'm trying to cover a lot of ground with these tutorials, so I'm sorry if I leave out some parts at first, I'll get to them.
    Wow I changed my sig!

  4. #13
    outsid3r's Avatar
    outsid3r is offline Programming God
    Join Date
    Jul 2008
    Posts
    621
    Rep Power
    19

    Re: On Learning the STL: Chapter 1 (Vectors) - Part 1

    that's great

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. learning python part 4 (a look at functions)
    By saeras in forum Python Tutorials
    Replies: 2
    Last Post: 09-22-2011, 03:13 PM
  2. Learning Python part 0 (prelude)
    By saeras in forum Python Tutorials
    Replies: 8
    Last Post: 07-23-2011, 12:04 PM
  3. Learning Pygame(simple 2d), part 1
    By spyder in forum Python Tutorials
    Replies: 0
    Last Post: 07-24-2010, 02:24 PM
  4. Learning python part 5 (modules)
    By saeras in forum Python Tutorials
    Replies: 1
    Last Post: 02-19-2010, 04:21 AM
  5. On Learning the STL: Chapter 1 (Vectors) - Part 2
    By ZekeDragon in forum C Tutorials
    Replies: 2
    Last Post: 08-11-2009, 12:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts