zoukankan      html  css  js  c++  java
  • 集合框架(五)

    一、继承关系

    AbstractList<-Vector<-Stack
    

    二、Vector

    下面这段话来自Java 8的说明文档:

    As of the Java 2 platform v1.2, this class was retrofitted to implement the List interface, making it a     member of the Java Collections Framework. Unlike the new collection implementations, Vector is synchronized.     If a thread-safe implementation is not needed, it is recommended to use ArrayList in place of Vector. 
    

    Vector中List的实现方式和ArrayList基本一样,不过Vector是同步的。

    三、Statck

    下面这段话来自Java 8的说明文档:

    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with five operations     that allow a vector to be treated as a stack. The usual push and pop operations are provided, as well as a method     to peek at the top item on the stack, a method to test for whether the stack is empty, and a method to search     the stack for an item and discover how far it is from the top.
    
        A more complete and consistent set of LIFO stack operations is provided by the Deque interface and its implementations,     which should be used in preference to this class. For example:
    
      Deque<Integer> stack = new ArrayDeque<Integer>();  
    

    Stack继承了Vector,并提供了一些自己的方法,实现了List的后进先出的队列。Deque接口和其实现者为"后进先出"队列提供了提供了 更多的操作

    四、总结

    Vector和Stack都可以看做是Java1.2前的遗留产物,而且都是同步的(线程暂时不是很懂),List的实现一般使用ArrayList(快速随机访问) 或LinkedList(快速插入或删除操作)。

    All rights reserved please indicate the source if reprint---吓尿了的大肥鼠
  • 相关阅读:
    [PyJs系列介绍]一、从commonjs和seajs说起
    [PyJs系列介绍]五、回顾及展望
    [PyJs系列介绍]三、编译与上线
    url decode problem
    [PyJs系列介绍]二、缘起和核心概念
    ControlJS介绍
    css,javascript的预加载
    [PyJs系列介绍]四、代理与插件
    webservice上传图片
    提高IIS7并发连接数
  • 原文地址:https://www.cnblogs.com/realsoul/p/5706159.html
Copyright © 2011-2022 走看看