Java Review (xxiii collection ----- Overview)

Article Directory


The initial version of Java provides only a small set of classes for the most commonly used data structures: Vector, Stack, Hashtable, BitSet and Enumeration interface.

With the advent of Java SE 1.2, designers feel it is time to launch a full-featured set of data structures of the. Face a lot of conflicting design strategy, they want to make the library a small and easy to learn, do not want or as complex as C ++ "Standard Template Library" (STL), and yet want to be able to absorb STL pioneered " generic algorithms "has the advantage.

They want the traditional class financial framework for the new man in. As with all collections library designers, they have to make some hard choices, then, throughout the design process, they made some unique design decisions.


As is often the case of modern data structure libraries, Java class libraries will also be a collection of interfaces (interface) separate from the implementation (implementation).

Java collection classes derive primarily consists of two interfaces out: Collection and Map, Collection and Map is the root of the Java Collections Framework interfaces, two interfaces also contains a number of sub-interfaces or implementation classes.

Figure I: Java collection system

Here Insert Picture Description

Second, as shown in FIG Collection interface, sub-interface inheritance tree and its implementation class:


Figure II: Collection inheritance tree collection system

Here Insert Picture Description

Figure 2 shows the system in the Collection set, wherein the thick lines and the Set List interface are derived two sub Collection interface interfaces, which represent a set of unordered and ordered set; Queue queue implementation is provided by Java.

Inheritance tree is shown in Figure III Map system, all Map implementation class for storing data having a mapping relationship.

Figure III: Map collection system inheritance tree

Here Insert Picture Description

Figure 3 shows a number of classes implement the Map interface, the implementation class there are some differences in function, usage, but they have a functional feature: each item of data are stored in the Map key-value pairs , i.e. the key and value two values.

Like the report card: Language -79, -80 mathematics, each performance consists of two values, namely the subject name and achievements. For a transcript, the subjects usually do not repeat, and the results are repeatable, common practice to review accomplishments on the subject, and not subject to review based on the results.

Map Similarly, Map where the key can not be duplicated , used to identify the collection of key data for each, if you need access to data in the Map, always acquired on the basis of key Map.

Figures 2 and 4 for three thick line interfaces identified in Figure, all Java can be set into three categories, wherein:

  • Set like a collection jar, add an object to the collection of Set, Set collection can not remember the order of addition of this element, so Set, the elements can not be repeated (otherwise the system can not accurately identify this element);
  • List very much like a collection array, which remembers the order of each added element, and a variable length List;
  • Map set, like a jar, but each item of data inside it consists of two values.


Figure 4: a schematic view of a set of three kinds of

Here Insert Picture Description



Reference:
[1]: "Java core technology Volume I"
[2]: "crazy Java handouts"
[3]: Java Collections Framework | newbie tutorial

Published 136 original articles · won praise 36 · views 30000 +

Guess you like

Origin blog.csdn.net/sinat_40770656/article/details/102963055