Generics, linked list

Source: Internet
Author: User
Tags java se

Generics are a new feature of Java SE 1.5, and the nature of generics is a parameterized type, meaning that the data type being manipulated is specified as a parameter. This type of parameter can be used in the creation of classes, interfaces, and methods, called generic classes, generic interfaces, and generic methods, respectively. The benefits of introducing generics into the Java language are simple and secure.
In the case of Java SE 1.5, without generics, the "arbitrariness" of arguments is implemented by reference to type object, and the disadvantage of "arbitrariness" is to make explicit coercion of type conversions, which require the developer to be able to predict the actual parameter type. In the case of coercion of type conversion errors, the compiler may not prompt for an error and an exception occurs at run time, which is a security risk.
The benefit of generics is that it checks for type safety at compile time, and all casts are automatic and implicit to increase the rate of reuse of the code.
Limitations of generics:
1. A generic type parameter can only be a class type (including a custom class) and cannot be a simple type.
2, the same generic can correspond to multiple versions (because the parameter type is indeterminate), different versions of the generic class instances are incompatible.
3, generic type parameters can have more than one.
4. Parameter types of generics can use extends statements, such as <t extends Superclass>. It is customary to call it "bounded type".
5. The parameter type of a generic type can also be a wildcard type. For example class<?> ClassType = Class.forName ("java.lang.String");

The      linked list is a non-sequential, non-sequential storage structure on a physical storage unit, and the logical order of the data elements is achieved through the order of the pointers in the linked list. A linked list consists of a series of nodes (each element in the list is called a node) that can be dynamically generated at run time. Each node consists of two parts: one is the data field that stores the data element, and the other is the pointer field that stores the next node address. The operation is complex compared to the linear table order structure. Since they do not have to be stored sequentially, the list can achieve an O (1) complexity at the time of insertion, much faster than another linear table-order table, but the time to find a node or to access a particular numbered node requires O (n), while the corresponding time complexity of the linear and sequential tables is O (Logn) and O (1) respectively. Using the list structure can overcome the shortcoming that the array list needs to know the data size beforehand, the list structure can make full use of the computer memory space and realize the flexible memory dynamic management. However, the list loses the advantage of random array reading, and the spatial overhead of the linked list is larger due to the increase of the point-of-view pointer domain. The most obvious benefit of a linked list is that the regular array arranges the associated items in a different way than the data items are in the order of memory or disk, and the data accesses tend to be converted in different permutations. Lists allow you to insert and remove nodes from any location on the table, but do not allow random access. There are a number of different types of linked lists: one-way lists, two-way lists, and circular lists. Linked lists can be implemented in a variety of programming languages. The built-in data types of languages like Lisp and scheme include the access and operation of the linked list. Programming languages or object-oriented languages such as c,c++ and Java rely on variable tools to generate linked lists. Features of the   list: The characteristic of the chain storage representation of linear tables is to store the data elements of a linear table in a set of arbitrary storage units (this set of storage units can be contiguous or discontinuous). Therefore, in order to represent the logical relationship between each data element   its immediate successor data element, in addition to storing its own information, it is necessary to store a message indicating its direct successor (that is, the direct successor storage location). These two pieces of information form a "node" (as shown in the figure next to the overview), representing a data element in a linear table. The linear table of the chain storage, there is a drawback is to find a number, you have to start from scratch, very troublesome. Depending on the situation, you can also design other extensions of the list yourself. However, the data is not usually appended to the edge because the list of points and edges is basically one by one (except for the first or last node, but no special case is created). One exception is that if the list supports reversing the front and back pointers in a segment of the list, it may be more convenient to add the reverse tag to the edge. For non-linear linked lists, see related other data structures, such as trees, graphs. There is also a data structure based on multiple linear lists: Jump table, INSERT, Delete and find basic operations such as the speed can reach O (nlogn), and balanced binary tree. The domain in which the data element information is stored is called the data domain, and the domain where the direct successor is stored is referred to as the Pointer field (set the domain name to next). The information stored in the pointer field is also called a pointer or chain. By the distinction, ..., the N-nodes chain-linked list, called the linear table chain storage representation, because each node of such a list contains only one pointer field, it is also called a single-linked list or a linear list.

Generics, linked list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.