1 / 7

Useful Data Structures in C++ and Java

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.

baka
Download Presentation

Useful Data Structures in C++ and Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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();

More Related