Thread: one of the STL libraries

  1. #1
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916

    one of the STL libraries

    I don't know which one it is. I've never used the STL before, and I'm just getting started, and finding that using it doesn't appear to be horribly difficult. I just need clarification on one thing... which one of the libraries is like a linked list, but only adds a new element if it doesn't exist anywhere else in the list? Like, if I tried to added "1,2,3,4,5,6" to the list, and then tried to add 5 again, it wouldn't do anything. Hmmm... I think there is one. Am I wrong?
    Away.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    148
    std::set in <set>

  3. #3
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    haha, I decided that instead of reading, I would program my own for this... it didn't take as long as I thought it would... lol. I'm a loser.
    Away.

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    There's only one STL. What you're looking for is an STL container.

  5. #5
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    std::list also has a function, unique() which removes adjacent identical elements.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #6
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Also note, <algorithm> defines a generic std::unique algorithm which does the same.

  7. #7
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Just remember the key thing with the unique function is that the elements in the container are required to be sorted prior to its use.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. STL vs ATL
    By donglee in forum C++ Programming
    Replies: 3
    Last Post: 04-09-2009, 02:37 PM
  2. MinGW thread-safe runtime libraries
    By Mario F. in forum C++ Programming
    Replies: 3
    Last Post: 08-21-2006, 08:15 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM