SlideServe
Menu
Préférences
© SlideServe · v2026

Useful Data Structures in C++ and Java

leals avatar
7 diapositives · 109 Views · Jan 05, 2020

Useful Data Structures in C++ and Java. Useful Data Structures in C++ (1). Templates are C++’s mechanism to define abstract objects which can be parameterized by type.

Useful Data Structures in C++ and Java - slide 1
01 / 7Useful Data Structures in C++ and Java
1 / 17

Télécharger la présentation

Useful Data Structures in C++ and Java
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Useful Data Structures in C++ and Java

  2. Useful Data Structures in C++ (1) • Templates are C++’s mechanism to define abstract objects which can be parameterized by type. • The C++ Standard Template Library (STL) provides implementations of many useful data structures, such as stacks, queues, dictionaries, priority queues, and sets.

  3. Useful Data Structures in C++ (3) • Stack – S.push(), S.top(), S.pop(), S.empty(). You should always top on pop because top returns but does not remove the element on top, while pop removes but does not return the element. • Queue – Q.front(), Q.back(), Q.push(), Q.pop(), and Q.empty(). Queue have the same idiosyncrasies as stack.

  4. Useful Data Structures in C++ (3) • Dictionary – STL contains a wide variety of containers, including hash_map, a hashed associative container binding keys to data items. Methods include H.erase(), H.find(), and H.insert() • Priority Queue – Declared priority-queue<int> Q;, methods include Q.top(), Q.push, Q.pop(), and Q.empty(). • Set – Sets are represented as sorted associative containers, declared set<key, comparison> S;. Set algorithms include set_union and set_intersection, as well as other standard set operators.

  5. Useful Data Structures in Java (1) • Useful standard Java objects appear in the java.util package. Below are some useful objects related to data structures. • To use java.util include import java.util.*; at the beginning of your program to improt the whole package.

  6. Useful Data Structures in Java (2)

  7. Useful Data Structures in Java (3) • You can declare a data structure object with an interface or abstract class and instantiate it using a concrete class, likeMap myMap = new HashMap(); • Or you can declare a data structure object and instantiate it with a concrete class, likeHashMap myMap = new HashMap();