1 22 23 package com.sosnoski.util.array; 24 25 36 37 public class DoubleArray extends ArrayBase 38 { 39 40 protected double[] m_baseArray; 41 42 49 50 public DoubleArray(int size, int growth) { 51 super(size, growth, double.class); 52 } 53 54 60 61 public DoubleArray(int size) { 62 super(size, double.class); 63 } 64 65 68 69 public DoubleArray() { 70 this(DEFAULT_SIZE); 71 } 72 73 78 79 public DoubleArray(DoubleArray base) { 80 super(base); 81 } 82 83 89 90 protected final Object getArray() { 91 return m_baseArray; 92 } 93 94 100 101 protected final void setArray(Object array) { 102 m_baseArray = (double[]) array; 103 } 104 105 111 112 public final int add(double value) { 113 int index = getAddIndex(); 114 m_baseArray[index] = value; 115 return index; 116 } 117 118 124 125 public void add(int index, double value) { 126 makeInsertSpace(index); 127 m_baseArray[index] = value; 128 } 129 130 136 137 public final double get(int index) { 138 if (index < m_countPresent) { 139 return m_baseArray[index]; 140 } else { 141 throw new ArrayIndexOutOfBoundsException ("Invalid index value"); 142 } 143 } 144 145 151 152 public final void set(int index, double value) { 153 if (index < m_countPresent) { 154 m_baseArray[index] = value; 155 } else { 156 throw new ArrayIndexOutOfBoundsException ("Invalid index value"); 157 } 158 } 159 160 166 167 public double[] toArray() { 168 return (double[])buildArray(double.class, 0, m_countPresent); 169 } 170 171 179 180 public double[] toArray(int offset, int length) { 181 return (double[])buildArray(double.class, offset, length); 182 } 183 184 189 190 public Object clone() { 191 return new DoubleArray(this); 192 } 193 } 194 | Popular Tags |