| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 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.ShortCollection; |
| 23 | |
import org.apache.commons.collections.primitives.ShortIterator; |
| 24 | |
import org.apache.commons.collections.primitives.ShortList; |
| 25 | |
import org.apache.commons.collections.primitives.ShortListIterator; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | 552 | abstract class AbstractListShortList extends AbstractCollectionShortCollection implements ShortList { |
| 34 | |
|
| 35 | |
public void add(int index, short element) { |
| 36 | 53 | getList().add(index,new Short(element)); |
| 37 | 37 | } |
| 38 | |
|
| 39 | |
public boolean addAll(int index, ShortCollection collection) { |
| 40 | 3 | return getList().addAll(index,ShortCollectionCollection.wrap(collection)); |
| 41 | |
} |
| 42 | |
|
| 43 | |
public short get(int index) { |
| 44 | 15046 | return ((Number)getList().get(index)).shortValue(); |
| 45 | |
} |
| 46 | |
|
| 47 | |
public int indexOf(short element) { |
| 48 | 64 | return getList().indexOf(new Short(element)); |
| 49 | |
} |
| 50 | |
|
| 51 | |
public int lastIndexOf(short element) { |
| 52 | 64 | return getList().lastIndexOf(new Short(element)); |
| 53 | |
} |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
public ShortListIterator listIterator() { |
| 63 | 982 | return ListIteratorShortListIterator.wrap(getList().listIterator()); |
| 64 | |
} |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
public ShortListIterator listIterator(int index) { |
| 74 | 109 | return ListIteratorShortListIterator.wrap(getList().listIterator(index)); |
| 75 | |
} |
| 76 | |
|
| 77 | |
public short removeElementAt(int index) { |
| 78 | 100 | return ((Number)getList().remove(index)).shortValue(); |
| 79 | |
} |
| 80 | |
|
| 81 | |
public short set(int index, short element) { |
| 82 | 50 | return ((Number)getList().set(index,new Short(element))).shortValue(); |
| 83 | |
} |
| 84 | |
|
| 85 | |
public ShortList subList(int fromIndex, int toIndex) { |
| 86 | 166 | return ListShortList.wrap(getList().subList(fromIndex,toIndex)); |
| 87 | |
} |
| 88 | |
|
| 89 | |
public boolean equals(Object obj) { |
| 90 | 39 | if(obj instanceof ShortList) { |
| 91 | 36 | ShortList that = (ShortList)obj; |
| 92 | 36 | if(this == that) { |
| 93 | 3 | return true; |
| 94 | 33 | } else if(this.size() != that.size()) { |
| 95 | 4 | return false; |
| 96 | |
} else { |
| 97 | 29 | ShortIterator thisiter = iterator(); |
| 98 | 29 | ShortIterator thatiter = that.iterator(); |
| 99 | 148 | while(thisiter.hasNext()) { |
| 100 | 121 | if(thisiter.next() != thatiter.next()) { |
| 101 | 2 | return false; |
| 102 | |
} |
| 103 | |
} |
| 104 | 27 | return true; |
| 105 | |
} |
| 106 | |
} else { |
| 107 | 3 | return false; |
| 108 | |
} |
| 109 | |
} |
| 110 | |
|
| 111 | |
public int hashCode() { |
| 112 | 938 | return getList().hashCode(); |
| 113 | |
} |
| 114 | |
|
| 115 | |
final protected Collection getCollection() { |
| 116 | 8859 | return getList(); |
| 117 | |
} |
| 118 | |
|
| 119 | |
abstract protected List getList(); |
| 120 | |
} |