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

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

  1. #11
    Programming God outsid3r has a spectacular aura about outsid3r has a spectacular aura about outsid3r's Avatar
    Join Date
    Jul 2008
    Location
    Portugal
    Posts
    564

    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 06:28 AM.

  2. #12
    Moderator ZekeDragon is a name known to all ZekeDragon is a name known to all ZekeDragon is a name known to all ZekeDragon is a name known to all ZekeDragon is a name known to all ZekeDragon is a name known to all ZekeDragon's Avatar
    Join Date
    Jul 2009
    Location
    Nowhere, Washington
    Posts
    1,780
    Blog Entries
    40

    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.
    Should I get a userbar here?

  3. #13
    Programming God outsid3r has a spectacular aura about outsid3r has a spectacular aura about outsid3r's Avatar
    Join Date
    Jul 2008
    Location
    Portugal
    Posts
    564

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

    that's great

+ Reply to Thread
Page 2 of 2
FirstFirst 1 2

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Validation - Part 2 - Client-Side
    By Kernel in forum News
    Replies: 0
    Last Post: 04-28-2009, 01:40 AM
  2. Replies: 0
    Last Post: 12-25-2008, 07:11 AM
  3. Learning On A Project
    By Kernel in forum News
    Replies: 0
    Last Post: 10-10-2008, 06:10 AM
  4. ROBOT ASSEMBLY-- C language
    By hummer350 in forum C and C++
    Replies: 3
    Last Post: 07-31-2008, 10:03 PM
  5. Replies: 0
    Last Post: 05-05-2008, 07:43 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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