1 17 package org.apache.commons.collections.primitives.adapters; 18 19 import java.util.Collection ; 20 import java.util.List ; 21 22 import org.apache.commons.collections.primitives.DoubleCollection; 23 import org.apache.commons.collections.primitives.DoubleIterator; 24 import org.apache.commons.collections.primitives.DoubleList; 25 import org.apache.commons.collections.primitives.DoubleListIterator; 26 27 33 abstract class AbstractListDoubleList extends AbstractCollectionDoubleCollection implements DoubleList { 34 35 public void add(int index, double element) { 36 getList().add(index,new Double (element)); 37 } 38 39 public boolean addAll(int index, DoubleCollection collection) { 40 return getList().addAll(index,DoubleCollectionCollection.wrap(collection)); 41 } 42 43 public double get(int index) { 44 return ((Number )getList().get(index)).doubleValue(); 45 } 46 47 public int indexOf(double element) { 48 return getList().indexOf(new Double (element)); 49 } 50 51 public int lastIndexOf(double element) { 52 return getList().lastIndexOf(new Double (element)); 53 } 54 55 62 public DoubleListIterator listIterator() { 63 return ListIteratorDoubleListIterator.wrap(getList().listIterator()); 64 } 65 66 73 public DoubleListIterator listIterator(int index) { 74 return ListIteratorDoubleListIterator.wrap(getList().listIterator(index)); 75 } 76 77 public double removeElementAt(int index) { 78 return ((Number )getList().remove(index)).doubleValue(); 79 } 80 81 public double set(int index, double element) { 82 return ((Number )getList().set(index,new Double (element))).doubleValue(); 83 } 84 85 public DoubleList subList(int fromIndex, int toIndex) { 86 return ListDoubleList.wrap(getList().subList(fromIndex,toIndex)); 87 } 88 89 public boolean equals(Object obj) { 90 if(obj instanceof DoubleList) { 91 DoubleList that = (DoubleList)obj; 92 if(this == that) { 93 return true; 94 } else if(this.size() != that.size()) { 95 return false; 96 } else { 97 DoubleIterator thisiter = iterator(); 98 DoubleIterator thatiter = that.iterator(); 99 while(thisiter.hasNext()) { 100 if(thisiter.next() != thatiter.next()) { 101 return false; 102 } 103 } 104 return true; 105 } 106 } else { 107 return false; 108 } 109 } 110 111 public int hashCode() { 112 return getList().hashCode(); 113 } 114 115 final protected Collection getCollection() { 116 return getList(); 117 } 118 119 abstract protected List getList(); 120 } 121 | Popular Tags |