Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2091222
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: Java

2011-05-15 17:57:44

  1. Docs
  2. Classes Diagram

  3. Old Classes
    1. 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.
    2. Stack
      Stack is a Last-In/First-Out(LIFO) data structure.
    3. BitSet
      The BitSet class implements a bit field. Each element in a BitSet can be on(1) or off(0).
    4. Enumeratioin
    5. xxx
  4. New Classes
    Collection
    1. 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.
    2. 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).
    3. 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
    4. 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
    5. Hashtable is a synchronized implementation of Map.
      1. Properties is a Hashtable where the keys and values must be Strings.


    6. Arrays
      Arrays contains static methods which operate on arrays.
    7. 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
    8. xxx
  5. 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
  6. 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.
  7. xxx
阅读(728) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~