1 package org.djunits.value.vdouble.vector;
2
3 import java.util.List;
4 import java.util.SortedMap;
5
6 import org.djunits.unit.PowerUnit;
7 import org.djunits.value.StorageType;
8 import org.djunits.value.ValueException;
9 import org.djunits.value.vdouble.scalar.Power;
10
11
12
13
14
15
16
17
18
19
20
21
22 public class MutablePowerVector extends AbstractMutableDoubleVectorRel<PowerUnit, PowerVector, MutablePowerVector, Power>
23 {
24
25 private static final long serialVersionUID = 20151109L;
26
27
28
29
30
31
32
33
34 public MutablePowerVector(final double[] values, final PowerUnit unit, final StorageType storageType) throws ValueException
35 {
36 super(values, unit, storageType);
37 }
38
39
40
41
42
43
44
45
46 public MutablePowerVector(final List<Double> values, final PowerUnit unit, final StorageType storageType)
47 throws ValueException
48 {
49 super(values, unit, storageType);
50 }
51
52
53
54
55
56
57
58 public MutablePowerVector(final Power[] values, final StorageType storageType) throws ValueException
59 {
60 super(values, storageType);
61 }
62
63
64
65
66
67
68
69 public MutablePowerVector(final List<Power> values, final StorageType storageType) throws ValueException
70 {
71 super(values, storageType);
72 }
73
74
75
76
77
78
79
80
81
82 public MutablePowerVector(final SortedMap<Integer, Power> values, final int length, final StorageType storageType)
83 throws ValueException
84 {
85 super(values, length, storageType);
86 }
87
88
89
90
91
92
93
94
95
96 public MutablePowerVector(final SortedMap<Integer, Double> values, final PowerUnit unit, final int length,
97 final StorageType storageType) throws ValueException
98 {
99 super(values, unit, length, storageType);
100 }
101
102
103
104
105
106 MutablePowerVector(final DoubleVectorData data, final PowerUnit unit)
107 {
108 super(data, unit);
109 }
110
111
112 @Override
113 protected final PowerVector instantiateType(final DoubleVectorData dvd, final PowerUnit unit)
114 {
115 return new PowerVector(dvd, unit);
116 }
117
118
119 @Override
120 protected final MutablePowerVector instantiateMutableType(final DoubleVectorData dvd, final PowerUnit unit)
121 {
122 return new MutablePowerVector(dvd, unit);
123 }
124
125
126 @Override
127 protected final Power instantiateScalar(final double value, final PowerUnit unit)
128 {
129 return new Power(value, unit);
130 }
131
132
133 @Override
134 public final MutablePowerVector toDense()
135 {
136 return this.data.isDense() ? (MutablePowerVector) this : instantiateMutableType(this.data.toDense(), getUnit());
137 }
138
139
140 @Override
141 public final MutablePowerVector toSparse()
142 {
143 return this.data.isSparse() ? (MutablePowerVector) this : instantiateMutableType(this.data.toSparse(), getUnit());
144 }
145
146
147
148
149
150
151 public Power[] toArray()
152 {
153 Power[] array = new Power[size()];
154 for (int i = 0; i < size(); i++)
155 {
156 try
157 {
158 array[i] = get(i);
159 }
160 catch (ValueException exception)
161 {
162 throw new RuntimeException(exception);
163 }
164 }
165 return array;
166 }
167
168 }