-3

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.

Stackuser
  • 140
  • 1
  • 12

3 Answers3

5

"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 , 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
2

Yes, of course, see for yourself.

If the standard library is not fancy enough for your needs, have a look at Boost !

Quentin
  • 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
  • Should we close this as a link only answer? – πάντα ῥεῖ Dec 26 '14 at 18:43
  • @πάνταῥεῖ 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
0

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
ravi
  • 10,994
  • 1
  • 18
  • 36