摘要: 用 链表也能同样实现, 我这里值用了数组的实现。package cn.com.test04;class MyStack{ private Object[] obj; private int i=0; MyStack(){ this(10); } MyStack(int length){ obj=new Object[length]; } public void push(T t){ obj[i++]=t; } public T pop(){ retu... 阅读全文
posted @ 2014-04-10 11:35 家徒四壁全是伤 阅读(345) 评论(0) 推荐(0) 编辑
摘要: 此hashmap中使用到MyArrayList 阅读前 请先看 我写的MyArrayListpackage cn.com.test04;class MyIterator{ private MyArrayList li; int i=0; MyIterator(MyArrayList li){ this.li=li; } public boolean hasNext(){ if(i{ private Node[] node; MyHashMap(){ this(10); } MyHa... 阅读全文
posted @ 2014-04-10 11:28 家徒四壁全是伤 阅读(229) 评论(0) 推荐(0) 编辑
摘要: package cn.com.test04;class MylinkedList{ private Node head;// 头节点 private int size=0;// 记录元素个数 private Node aa;//相当于一个指针 public void add(T o){ Node en = new Node(o,null); if(head==null){ aa=head=en; }else{ aa.next=en; aa=en; } ... 阅读全文
posted @ 2014-04-10 11:12 家徒四壁全是伤 阅读(284) 评论(0) 推荐(0) 编辑
摘要: package cn.com.test04;import java.util.ArrayList;import java.util.Arrays;class MyArrayList{ private Object[] obj; private int size=0; MyArrayList(){ this.obj= new Object[10];//this(10); } MyArrayList(int length){ this.obj= new Object[length]; } public vo... 阅读全文
posted @ 2014-04-10 11:09 家徒四壁全是伤 阅读(364) 评论(0) 推荐(0) 编辑