Thread: STL code

  1. #1
    Registered User
    Join Date
    Nov 2008

    STL code

    I'm trying to find code that is used in the STL.

    I have an assignment where we are to use stacks / queues, but he wants us to build the stack using a class and write our own functions for push/pop. I've got my program working using STL stuff, but now need to modify it and write my own class/functions. I'm not really sure what I need to do, and honestly don't understand why he likes to make us do things like this ( I get once or twice at the beginning, to get us to appreciate other people's work and how they've made things easier for us...but we're beyond the first or second program at this point and get that it's nice that someone wrote these libraries for us to use ...)

    Can you point me in a direction to how to read / find the code that is written for these things so I can make an attempt at writing my own?

  2. #2
    Join Date
    Oct 2007
    Inside my computer
    The point is that you should understand how these things work and get familiar with writing algorithms. You should not look at some STL code. You should make your own code.
    Start with lining out the requirements: what functions should be there and what should they do?
    Then write a flowchart describing how these functions would go about the task they need to do.
    Then translate to code.

    Check back if you get stuck with any of these steps.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jun 2005
    The whole point of your current exercise is to reason out how to implement such things on your own. It is not to take the good work someone else has done (the authors of the STL) and repackage it. The point of the exercise is that you describe what a stack or a queue is, work out how what data structures are needed to represent it, and then reason out how you push or pop elements onto those data structures.

    You will be wasting your time looking at STL source right now. Even using the basic techniques, let alone code, from the STL will ring alarm bells for whoever marks your exercise - not even prodigies at your stage of learning would use them, unless they have cheated.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Having used the STL for a long time I wouldn't even look at the source code for it. The source for the Microsoft version of the STL is atrocious. You would be better served analyzing the core data structure and then synthesizing your own code. I assure you that you will gain nothing but a headache by looking at the STL source.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Array of Vectors amd other STL questions
    By kolistivra in forum C++ Programming
    Replies: 16
    Last Post: 04-12-2007, 09:11 AM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM