当前位置:网站首页>List interface three sub implementation classes
List interface three sub implementation classes
2022-06-23 08:18:00 【Liang FuFu】
1. List Three sub implementation classes
1.1 List Set three sub implementation class characteristics
1.ArrayList: It is our common , In a single threaded program , The highest efficiency of execution .(List Set default use )
The underlying structure is an array structure : Quick query , Add or delete slowly .
Is a thread unsafe class , Out of sync .
2.Vector: The underlying data structure is also an array , Quick query , Add or delete slowly
Is a thread safe class , Sync , Inefficient execution
3.LinkedList: The underlying data structure is a linked list : Slow query , Additions and deletions quickly
Thread unsafe class , Efficient
1.2 Vector aggregate
1. Unique features :
public void addElement(E obj): stay Vector Add a new element to the end of the collection
public E elementAt(int index): Get the element at the specified location
public Enumeration<E> elements(): It's like an iterator , Unique method
Enumeration Interface
boolean hasMoreElements(): Whether there are more components ( Elements ) Traversable
E nextElement(): Get next element
2.Vector There are two more traversals
public E elementAt(int index) and size() Methods combined with common for
example :for(int x=0;x<Vector.size();x++){
String s = Vector.elementAt(x);
sout(s);
}
public Enumeration<E> elements():Vector The unique iterator operation of
boolean hasMoreElements(): Whether there are more components ( Elements ) Traversable
E nextElement(): Get next element
example :Enumeration<String> enumeration = Vector.elements();
while(enumeration.hasMoreElements()){
String s = enumeration.nextElement();
System.out.println(s);
}
1.3 LinkedList aggregate
1. Unique features :public void addFirst(Object e): Add any type of element to the beginning of the linked list every time
public void addLast(Objet e): Every time an element of any type is conditioned to the end of the linked list
public Object removeFirst() Remove and return the first element from this list .
public Object removeLast() Delete from this list and return the last element
public Object getFirst(): Get the first element of the linked list
public Object getLast(): Get the last element of the linked list
2. utilize LinkedList Realize stack function
public class MyStack{
private LinkedList list;
public MyStack(){
list = new LinkedList<>;
}
public void add(Object obj){
list.addFirst(obj);
}
public Object get(){
return list.removeFirst();
}
public boolean isEmpty(){
return link.isEmpty();
}
}
public class Test{
main();
MyStack mystack = new MyStack();
mystack.add("hello");
mystack.add("world");
mystack.add("javaee");
while(!MyStack.isEmpty()){
Object o = mystack.get();
sout(o);
}
}
边栏推荐
- Object.defineProperty() 和 数据代理
- MFC radio button grouping
- The rtsp/onvif protocol video platform easynvr startup service reports an error "service not found". How to solve it?
- aquatone工具 中的2个bug修复
- vector的深度剖析及模拟实现
- Ad object of Active Directory
- 4-绘制椭圆、使用定时器
- 给你的win10装一个wget
- 点云库pcl从入门到精通 第十章
- Vulnhub | dc: 3 | [actual combat]
猜你喜欢

Basic use of check boxes and implementation of select all and invert selection functions

坑爹的“敬业福”:支付宝春晚红包技术大爆发

“方脸老师”董宇辉再回应热度下降:把农产品直播做好让农民受益 考虑去支教

ThreadPoolExecutor线程池实现原理与源码解析

Ignore overlength parameter violation
![[try to hack] IP address](/img/ab/ed91f3094ac913a0d79448a2d19015.png)
[try to hack] IP address

Socket socket programming
![Vulnhub | dc: 4 | [actual combat]](/img/33/b7422bdb18f39e9eb55855dbf1d584.png)
Vulnhub | dc: 4 | [actual combat]

vtk.js鼠標左鍵滑動改變窗比特和窗寬

复选框的基本使用与实现全选和反选功能
随机推荐
MFC radio button grouping
Two bug fixes in aquatone tool
Set接口和Set子实现类
Capturing packets to find repeated acks and a large number of TCP retransmissions in TCP sessions -- sack (selective acknowledgement) technology
观察者模式
Create an orderly sequence table and perform the following operations: 1 Insert element x into the table and keep it in order; 2. find the element with the value of X, and delete it if found; 3. outpu
How to solve the problem that flv video stream cannot be played and TS file generation fails due to packet loss?
1-渐变、阴影和文本
PHP serialization and deserialization CTF
How to start Jupiter notebook in CONDA virtual environment
值得反复回味的81句高人高语
After easynvr video is enabled, no video file is generated. How to solve this problem?
11 string function
目标检测中的多尺度特征结合方式
Imperva- method of finding regular match timeout
vtk. JS left mouse button sliding to change window level and window width
vtk.js鼠標左鍵滑動改變窗比特和窗寬
Vulnhub | dc: 3 | [actual combat]
vector的深度剖析及模拟实现
odoo项目 发送信息到微信公众号或企业微信的做法