Function Description of the Collection class

xiaoxiao2021-03-06  14

First, in Java2, it is called: Collection API

JDK 1.2 Collection Interface List (Interface)

----------------------------------

| Interface Name | Description |

| --------------------------------------

| Collection | Implement a sorted object group. The collection is sometimes referred to as a package (BAG), |

| | Cause is to allow duplication, and do not limit the type or order of elements |

| --------------------------------------

Comparator | Provide a basic mechanism for comparing elements in a collection |

| --------------------------------------

| Iterator | Provide the basic mechanism of the elements in a collection of iteration |

| --------------------------------------

| List | Extend the Collection interface to implement an ordered collection of an object. |

| | This ordered list can be indexed and can contain repetitive values ​​|

| --------------------------------------

| Listiterator | Extend the Iterator interface to support the iteration of the list |

| --------------------------------------

| MAP | Provides the basic functions of using key values ​​to store and query data. The key value must be unique |

| --------------------------------------

| Map.Entry | MAP internal interface to develop a method of operating the "Key-Value" pair. |

| --------------------------------------

| SortedMap | A map, where the elements are sorted in ascending order. |

| --------------------------------------

| Set | Expand the Collection interface to implement a limited set, the set does not allow repeated values ​​|

| | And simple sets do not have a specific order. Some sets allow for empty values, but once |

| | Presence can only exist once |

| --------------------------------------

| SORTEDSET | A set, its element is sorted in ascending order. |

----------------------------------

JDK 1.2 Collection class (Class)

-----------------------------------

| Class name | Description |

| ------------------------------------- |

| Arrays | Provide search, row narrative group, and static ways to convert array to list || -------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------

| Collections | Provide search, sorting, and operations to implement the Collection interface pair |

| | Static method of icon |

| ------------------------------------- |

| AbstractCollection | Provide basic implementation of the Collection interface, and subject to other connections |

| | Dossual Extension |

| ------------------------------------- |

| AbstractList | Extend AbstractColleTion, and provide basic implementation of the List interface |

| ------------------------------------- |

| AbstractSequentialList | Extend AbstractList, and implement the functionality of sequential access list |

| | (Not a random access list) |

| ------------------------------------- |

| LinkedList | Extend AbstractSequentialList, and implement two-way linked list |

| ------------------------------------- |

| ArrayList | Extend AbstractList and implement an adjustable array |

| ------------------------------------- |

| AbstractSet | Extend AbstractCollection, and provide basic implementation of SET interface |

| ------------------------------------- |

| Hashset | Extend AbstractSet, and is a "key-value" pair. Give class |

The | | hash table to store, does not allow repeated values, nor can you use null values. |

| ------------------------------------- |

| TreeSet | Extend AbstractSet, and implement a support SortedSet interface |

| | Ordered binary tree. Denager values ​​are not supported in TreeSet. |

| ------------------------------------- |

| AbstractMap | Extend AbstractCollection and provide basic implementation to the MAP interface |

| ------------------------------------- |

| HashMap | Extend Abstractmap, and implement the "Key-Value" mapping, |

This class implements a hash table to store, and repeat values ​​are not allowed. Can use null values ​​|

| ------------------------------------- |

| TreeMap | Extend AbstractMap, and implement the support of sortedmap interface || | Order binary tree |

| ------------------------------------- |

| WeakHashMap | Extend AbstractMap, and implement mapping with weak keys. When the hash table |

The entry of the entry is collected by the garbage, which will be automatically deleted. |

-----------------------------------

Second, the Collection API points:

The Collection API provides a wide range of classes and interfaces.

Divide these interfaces and classes, you can get basic four types:

COLLECTION

Simple Collection can be disorderless and do not have to be restricted. You can use any one

Type objects, and an object can occur multiple times. Collection interface supports add, delete,

Summary and check the operation method of the collection.

2. List

List is an ordered collection that allows an object to appear multiple times. The order can be natural sort or according to the object

Add to the sequential order in the collection. Since the list is ordered, its object can be indexed.

The Listiterator interface provides a method of an iterative list. Abstract lists can be random,

Access to the array, through the linked list, or through a two-way linked list.

3. SET

SET is not allowed to have a set of repetition values. Some collections allow NULL values, but if they have NULL

This value can only be once again.

The AbstractSet and Hashset classes create a collection of no sorting.

The TREESET class creates a collection of sorting through a binary.

4. MAP

Map is a collection of data stored in a series of values ​​to find or index. With mapping, you can

A keyword (KEY) field for search. The keyword value must be unique.

In JDK1.2, mapping replaces dictionary and is used as the preferred technique for keywords and values.

The mapping created by Abstractmap, HashMap, WeakhashMap class is disorderless.

The TreeMap class creates a mapping that is sorted by a binary number.

Third, the basic type of storage value method:

An array

An array provides a storage mechanism for an ordered entry with a unique value.

An array can be used when the number of elements is fixed and there are specific values.

The sorting mechanism of the array makes it difficult to add and delete an element in an array.

If a group is full, you need to create a new array and copy the element of the current array before adding an element.

An array does not provide a special search mechanism.

2. Link list

The linked list provides storage mechanisms for ordered entry that does not require a unique value.

You can easily add and delete elements in the linked list. The length of a linked list can be dynamically changed.

Because each element points to the next (sometimes a forward one) element.

However, the speed of accessing the linked list is slower than the speed of the access array. The linked list does not provide a special search mechanism.

3. Tree

Tree provides storage mechanisms for ascending elements.

With the tree, you can easily add and delete elements, just keep the tree's order.

Search efficiency of the elements evenly distributed than the chain table and the tree group.

4. Hardery

In the hash table, each entry is represented by a pair of "key-value".

The key must be the unique identifier of the stored entry. With the key, you can find the elements in the hash table quickly and efficiently.

With the hash table, there will be some additional problems when calculating the hash value.

The hash table is best suited for large data sets.

转载请注明原文地址:https://www.9cbs.com/read-67684.html

New Post(0)