Java Notes
2019-04-08 本文已影响0人
翱翔云端
Java Collections Framework
计算机专业的应该知道,本专业最核心的一门课是数据结构与算法。
程序=数据结构+算法(一个获得图灵奖的公式)。
以上两点足以证明数据结构与算法在编程中的重要性了。
常用数据结构有哪些?
分类 | 数据结构 | Java实现 |
---|---|---|
线性结构 | 数组,线性表,队列,栈 | java.util.List<E>,java.util.Queue<E>,java.util.Stack<E>,java.util.Set<E> |
Key-Value结构 | 哈希表 | java.util.Map<K, V> |
树形结构 | 树 | 无 |
图形结构 | 图 | 无 |
算法 | 查找,排序等 | java.util.Arrays,java.util.Collections,java.util.TimSort<T> |
数据的存储存储结构只有两种:顺序存储(数组)和连式存储(链表)。
知道这些,再去学Java的集合架构,你不再是盲人摸象。
The Collection's family
Qualified Name | Comment |
---|---|
java.util.Collection<E> | The root interface in the collection hierarchy. |
java.util.AbstractCollection<E> | This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface. |
java.util.List<E> | An ordered collection (also known as a sequence). |
java.util.Queue<E> | A collection designed for holding elements prior to processing. |
java.util.Set<E> | A collection that contains no duplicate elements. |
The List's family
Qualified Name | Comment |
---|---|
java.util.List<E> | An ordered collection (also known as a sequence). |
java.util.AbstractList<E> | This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). For sequential access data (such as a linked list), AbstractSequentialList should be used in preference to this class. |
java.util.ArrayList<E> | Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is used internally to store the list. (This class is roughly equivalent to Vector, except that it is unsynchronized.) |
java.util.Vector<E> | This class implements a growable array of objects. |
java.util.LinkedList<E> | Doubly-linked list implementation of the List and Deque interfaces. |
The Queue's family
Qualified Name | Comment |
---|---|
java.util.Queue<E> | A collection designed for holding elements prior to processing. |
java.util.AbstractQueue<E> | This class provides skeletal implementations of some Queue operations. |
java.util.concurrent.BlockingQueue<E> | A java.util.Queue that additionally supports operations that wait for the queue to become non-empty when retrieving an element, and wait for space to become available in the queue when storing an element. |
java.util.Deque<E> | A linear collection that supports element insertion and removal at both ends. |
The Set's family
Qualified Name | Comment |
---|---|
java.util.Set<E> | A collection that contains no duplicate elements. |
java.util.AbstractSet<E> | This class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface. |
java.util.HashSet<E> | This class implements the Set interface, backed by a hash table (actually a HashMap instance). |
java.util.LinkedHashSet<E> | Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). |
java.util.SortedSet<E> | A Set that further provides a total ordering on its elements. The elements are ordered using their natural ordering, or by a Comparator typically provided at sorted set creation time. The set's iterator will traverse the set in ascending element order. Several additional operations are provided to take advantage of the ordering. (This interface is the set analogue of SortedMap.) |
The Map's family
Qualified Name | Comment |
---|---|
java.util.Map<K, V> | An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. |
java.util.AbstractMap<K, V> | This class provides a skeletal implementation of the Map interface, to minimize the effort required to implement this interface. |
java.util.HashMap<K, V> | Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key. (The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.) |
java.util.Hashtable<K, V> | This class implements a hash table, which maps keys to values. Any non-null object can be used as a key or as a value. |
java.util.LinkedHashMap<K, V> | Hash table and linked list implementation of the Map interface, with predictable iteration order. This implementation differs from HashMap in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is normally the order in which keys were inserted into the map (insertion-order). |
java.util.concurrent.ConcurrentMap<K, V> | A java.util.Map providing thread safety and atomicity guarantees. |
java.util.SortedMap<K, V> | A Map that further provides a total ordering on its keys. The map is ordered according to the natural ordering of its keys, or by a Comparator typically provided at sorted map creation time. This order is reflected when iterating over the sorted map's collection views (returned by the entrySet, keySet and values methods). Several additional operations are provided to take advantage of the ordering. (This interface is the map analogue of SortedSet.) |
Java Concurrent Programming
Qualified Name | Comment |
---|---|
java.lang.Thread | A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. |
java.lang.Runnable | The Runnable interface should be implemented by any class whose instances are intended to be executed by a thread. The class must define a method of no arguments called run. |
java.util.concurrent.Callable<V> | A task that returns a result and may throw an exception. Implementors define a single method with no arguments called call. |
java.util.concurrent.Future<V> | A Future represents the result of an asynchronous computation. Methods are provided to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation. |
java.util.concurrent.FutureTask<V> | A cancellable asynchronous computation. This class provides a baseimplementation of Future, with methods to start and cancela computation, query to see if the computation is complete, andretrieve the result of the computation. |
java.util.concurrent.Executor | An object that executes submitted Runnable tasks. |
java.util.concurrent.ExecutorService | An Executor that provides methods to manage termination andmethods that can produce a Future for tracking progress ofone or more asynchronous tasks. |
java.util.concurrent.AbstractExecutorService | Provides default implementations of ExecutorService execution methods. |
java.util.concurrent.ScheduledExecutorService | An ExecutorService that can schedule commands to run after a givendelay, or to execute periodically. |
java.util.concurrent.ThreadPoolExecutor | An ExecutorService that executes each submitted task using one of possibly several pooled threads, normally configuredusing Executors factory methods. |
java.util.concurrent.ScheduledThreadPoolExecutor | A ThreadPoolExecutor that can additionally schedulecommands to run after a given delay, or to execute periodically. This class is preferable to java.util.Timer when multiple worker threads are needed, or when the additional flexibility or capabilities of ThreadPoolExecutor (which this class extends) are required. |
java.util.concurrent.Executors | Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory, and Callable classes defined in this package. |