in C++ exists a library of common structure data, for example in Java there is java.util.Collection
with all its subclasses.
There is something similar also in C++? I would not write code for each data structure that I use.

- 140
- 1
- 12
3 Answers
"in C++ exists a library of common structure data, for example in Java there is
java.util.Collection
with all its subclasses. There is something similar also in C++?"
Yes, there's the standard c++ container's library, which will cover most of the data structures you're asking for.
A linked list is covered in particular by std::list
.
Though what's different to java, is that these container classes rely on abstract meta programming concepts to realize their interfaces, instead of having a single collection class interface to handle all of them.
The main points of common implementation, are the different types of iterator
concepts provided by particular container types
.
There may be more sophisticated container and data structure types provided by the boost container libraries, which aren't considered to be standard, but merely make up proposals, that might be incorporated into the next c++ standard's definition.

- 1
- 13
- 116
- 190
-
this post is in fact very clear and exhaustive, in the various comments of the other post much less .. but thanks for this answer. – Stackuser Dec 26 '14 at 20:10
-
OS Get a +1 - xmas present – Ed Heal Dec 26 '14 at 20:23
-
@EdHeal THX a lot! Get an `Ace of spades` from my side ;-) ... (I'm out of votes today beyond that last one, but we'll meet again soon, I'm sure) – πάντα ῥεῖ Dec 26 '14 at 20:26
-
Prefer a royal flush or a full house. – Ed Heal Dec 26 '14 at 20:29
Yes, of course, see for yourself.
If the standard library is not fancy enough for your needs, have a look at Boost !

- 62,093
- 7
- 131
- 191
-
what is the principal differences between STL and BOOST? As I understand it, STL is a official library of C++ , while BOOST is a "unofficial" library...that's right? – Stackuser Dec 26 '14 at 18:20
-
-
@πάνταῥεῖ nope. The question is "Does C++ have standard containers ?". The answer is "Yes". The rest is side information ;) – Quentin Dec 26 '14 at 19:33
-
@Stackuser STL is an old precursor of the C++ standard library. Boost is a huge open-source project, bearing no relation to the standard (although it has inspired it many times), and is widely recognized as an excellent library. – Quentin Dec 26 '14 at 19:35
-
@Quentin Well, elaborate about these points in your answer (seems they're more than just _side information_ in this case) – πάντα ῥεῖ Dec 26 '14 at 19:40
-
@Stackuser I'm just curious, what makes this answer superior to mine, that you finally accepted it? I'm willing to learn, and write better answers in the future ... – πάντα ῥεῖ Dec 26 '14 at 19:42
There's collection of all these data structures in C++ standard library. These are:-
Linked List :- std::list
Dynamic Array :- std::vector
Balanced Binary Tree :- std::set/std::map
Hash Table :- std::unordered_map

- 10,994
- 1
- 18
- 36