| 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 | |
|
| 21 | |
import org.apache.commons.collections.primitives.DoubleCollection; |
| 22 | |
import org.apache.commons.collections.primitives.DoubleIterator; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
abstract class AbstractCollectionDoubleCollection implements DoubleCollection { |
| 30 | 1331 | protected AbstractCollectionDoubleCollection() { |
| 31 | 1331 | } |
| 32 | |
|
| 33 | |
public boolean add(double element) { |
| 34 | 909 | return getCollection().add(new Double(element)); |
| 35 | |
} |
| 36 | |
|
| 37 | |
public boolean addAll(DoubleCollection c) { |
| 38 | 284 | return getCollection().addAll(DoubleCollectionCollection.wrap(c)); |
| 39 | |
} |
| 40 | |
|
| 41 | |
public void clear() { |
| 42 | 5 | getCollection().clear(); |
| 43 | 5 | } |
| 44 | |
|
| 45 | |
public boolean contains(double element) { |
| 46 | 792 | return getCollection().contains(new Double(element)); |
| 47 | |
} |
| 48 | |
|
| 49 | |
public boolean containsAll(DoubleCollection c) { |
| 50 | 14 | return getCollection().containsAll(DoubleCollectionCollection.wrap(c)); |
| 51 | |
} |
| 52 | |
|
| 53 | |
public String toString() { |
| 54 | 4 | return getCollection().toString(); |
| 55 | |
} |
| 56 | |
|
| 57 | |
public boolean isEmpty() { |
| 58 | 927 | return getCollection().isEmpty(); |
| 59 | |
} |
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
public DoubleIterator iterator() { |
| 69 | 3306 | return IteratorDoubleIterator.wrap(getCollection().iterator()); |
| 70 | |
} |
| 71 | |
|
| 72 | |
public boolean removeElement(double element) { |
| 73 | 96 | return getCollection().remove(new Double(element)); |
| 74 | |
} |
| 75 | |
|
| 76 | |
public boolean removeAll(DoubleCollection c) { |
| 77 | 12 | return getCollection().removeAll(DoubleCollectionCollection.wrap(c)); |
| 78 | |
} |
| 79 | |
|
| 80 | |
public boolean retainAll(DoubleCollection c) { |
| 81 | 14 | return getCollection().retainAll(DoubleCollectionCollection.wrap(c)); |
| 82 | |
} |
| 83 | |
|
| 84 | |
public int size() { |
| 85 | 3638 | return getCollection().size(); |
| 86 | |
} |
| 87 | |
|
| 88 | |
public double[] toArray() { |
| 89 | 1230 | Object[] src = getCollection().toArray(); |
| 90 | 1230 | double[] dest = new double[src.length]; |
| 91 | 20660 | for(int i=0;i<src.length;i++) { |
| 92 | 19430 | dest[i] = ((Number)(src[i])).doubleValue(); |
| 93 | |
} |
| 94 | 1230 | return dest; |
| 95 | |
} |
| 96 | |
|
| 97 | |
public double[] toArray(double[] dest) { |
| 98 | 3 | Object[] src = getCollection().toArray(); |
| 99 | 3 | if(dest.length < src.length) { |
| 100 | 1 | dest = new double[src.length]; |
| 101 | |
} |
| 102 | 60 | for(int i=0;i<src.length;i++) { |
| 103 | 57 | dest[i] = ((Number)(src[i])).doubleValue(); |
| 104 | |
} |
| 105 | 3 | return dest; |
| 106 | |
} |
| 107 | |
|
| 108 | |
protected abstract Collection getCollection(); |
| 109 | |
|
| 110 | |
} |