1 package com.mockobjects; 2 3 7 8 9 class ArrayList extends java.util.Vector { 10 11 14 public ArrayList() { 15 super(); 16 } 17 18 22 public ArrayList(int initialCapacity) { 23 super(initialCapacity); 24 } 25 26 31 public ArrayList(int initialCapacity, int capacityIncrement) { 32 super(initialCapacity, capacityIncrement); 33 } 34 35 public void add(Object item) { 36 super.addElement(item); 37 } 38 39 public void clear() { 40 super.removeAllElements(); 41 } 42 43 public boolean equals(ArrayList list) { 44 if (size() != list.size()) 45 return false; 46 47 for (int i = 0; i < size(); i++) { 48 if (!this.elementAt(i).equals(list.elementAt(i))) 49 return false; 50 } 51 return true; 52 } 53 54 public boolean equals(Object obj) { 55 if(obj instanceof ArrayList) 56 return equals((ArrayList)obj); 57 else 58 return false; 59 } 60 61 public Object get(int index) { 62 return super.elementAt(index); 63 } 64 65 public Iterator iterator() { 66 return new Iterator(this); 67 } 68 69 public Object [] toArray(Object [] result) { 70 for(int i=0;i<this.size();i++) { 71 result[i] = this.elementAt(i); 72 } 73 74 return result; 75 } 76 } 77 | Popular Tags |