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