- Docs
- Classes Diagram
- Old Classes
- Vector
Vector is an array (equivalent to ArrayList), and it is synchronized. This has a performance cost, if you do need very highly concurrent access, you should also consider CopyOnWriteArrayList.
- Stack
Stack is a Last-In/First-Out(LIFO) data structure.
- BitSet
The BitSet class implements a bit field. Each element in a BitSet can be on(1) or off(0).
- Enumeratioin
- xxx
- New Classes
Collection
- List:
A List is a collection which maintains an ordering for its elements. Every
element in the List has an index. Each element can thus be accessed by its
index, with the first index being zero. Normally, Lists allow duplicate
elements, as compared to Sets, where elements have to be unique.
- LinkedList is an implementation of List, backed by a doubly-linked list.
- ArrayList is an implementation of List, backed by an array.
- Vector is equivalent to ArrayList with synchronized operations.
- Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It is sub-class of Vector
- CopyOnWriteArrayList is a thread-safe random-access list. Read operations do not block and may overlap with update operations. Aggregate operationsare atomic.
- Set
A Set is a data structure like List, but it does not allow duplicate elements.
- SortedSet is a Set which iterates over its elements in a sorted order.
- TreeSet is an implementation of SortedSet.
- HashSet is an implementation of a Set, it is not sorted.
- LinkedHashSet
is a variant of HashSet. Its entries are kept in a doubly-linked list.
The iteration order is the order in which entries were inserted.
- EnumSet is a specialized Set to be used with enums as keys(elements).
- Queue
Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner.
- Queue
- PriorityQueue
A PriorityQueue holds elements on a priority heap, which orders the elements according to their natural order or according to the comparator specified at construction time. - xxx
- Map
A Map is a data structure consisting of a set of keys and values in which each key is mapped to a single value.
- SortedMap is a map that has its keys ordered.
- TreeMap is a map whose entries are sorted by their keys.
- HashMap
The iteration order for HashMap is non-deterministic. If you want
deterministic iteration, use .
- LinkedHashMap
LinkedHashMap is an implementation of that guarantees iteration order.
- WeakHashMap is an implementation of Map with keys which are
WeakReferences. A key/value mapping is removed when the key is no longer
referenced.
- IdentityHashMap
IdentityHashMap is a variant on HashMap which tests equality by reference
instead of equality by value. Basically, keys and values are compared for
equality by checking if their references are equal (eg obj1 == obj2) rather than by calling the
"equals" function.
- Hashtable
- Properties
- EnumMap
An Map specialized for use with Enum types as keys (elements).
- xxx
- Hashtable is a synchronized implementation of Map.
- Properties is a Hashtable where the keys and values must be Strings.
- Arrays
Arrays contains static methods which operate on arrays.
- Iterator
An iterator over a sequence of objects, such as a collection.
Generally, a collection class has a method:
Iterator iterator();
to create a iterator. Generally, the collection class need to implement its-own Iterator, such as ListIterator for List
There are 2 means to enumerate all elements of Collection:
A) Use Iterator
Collection c = xxx;
Iteratlr iter = c.iterator();
while (iter.hasNext())
{
MyType e = iter.next();
xxxx;
}
B) Use for-each
Collection c = xxx;
for (MyType e : c)
{
xxxx;
}
Note: If you want to define your-own collection class, and use for-each statements to enumerate all elements, the collection class must implement interface
- xxx
- Collection Sort
Collections.sort(collection-obj, comp-obj);
- Collections
Collections contains static methods which operate on Collection classes, such as sort, search, copy, compare, ...
- Comparable
- Comparator
- Performance
If a Collection object is only accessed in a single thread, non-thread-safe Collection is high performance, since synchronization operations will cost CPU.
- xxx
阅读(727) | 评论(0) | 转发(0) |