1 package org.djunits.value.vfloat.vector;
2
3 import java.util.List;
4 import java.util.SortedMap;
5
6 import org.djunits.unit.ForceUnit;
7 import org.djunits.value.StorageType;
8 import org.djunits.value.ValueException;
9 import org.djunits.value.vfloat.scalar.FloatForce;
10
11
12
13
14
15
16
17
18
19
20
21
22 public class MutableFloatForceVector
23 extends AbstractMutableFloatVectorRel<ForceUnit, FloatForceVector, MutableFloatForceVector, FloatForce>
24 {
25
26 private static final long serialVersionUID = 20151109L;
27
28
29
30
31
32
33
34
35 public MutableFloatForceVector(final float[] values, final ForceUnit unit, final StorageType storageType)
36 throws ValueException
37 {
38 super(values, unit, storageType);
39 }
40
41
42
43
44
45
46
47
48 public MutableFloatForceVector(final List<Float> values, final ForceUnit unit, final StorageType storageType)
49 throws ValueException
50 {
51 super(values, unit, storageType);
52 }
53
54
55
56
57
58
59
60 public MutableFloatForceVector(final FloatForce[] values, final StorageType storageType) throws ValueException
61 {
62 super(values, storageType);
63 }
64
65
66
67
68
69
70
71 public MutableFloatForceVector(final List<FloatForce> values, final StorageType storageType) throws ValueException
72 {
73 super(values, storageType);
74 }
75
76
77
78
79
80
81
82
83 public MutableFloatForceVector(final SortedMap<Integer, FloatForce> 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 MutableFloatForceVector(final SortedMap<Integer, Float> values, final ForceUnit unit, final int length,
98 final StorageType storageType) throws ValueException
99 {
100 super(values, unit, length, storageType);
101 }
102
103
104
105
106
107 MutableFloatForceVector(final FloatVectorData data, final ForceUnit unit)
108 {
109 super(data, unit);
110 }
111
112
113 @Override
114 protected final FloatForceVector instantiateType(final FloatVectorData dvd, final ForceUnit unit)
115 {
116 return new FloatForceVector(dvd, unit);
117 }
118
119
120 @Override
121 protected final MutableFloatForceVector instantiateMutableType(final FloatVectorData dvd, final ForceUnit unit)
122 {
123 return new MutableFloatForceVector(dvd, unit);
124 }
125
126
127 @Override
128 protected final FloatForce instantiateScalar(final float value, final ForceUnit unit)
129 {
130 return new FloatForce(value, unit);
131 }
132
133
134 @Override
135 public final MutableFloatForceVector toDense()
136 {
137 return this.data.isDense() ? (MutableFloatForceVector) this : instantiateMutableType(this.data.toDense(), getUnit());
138 }
139
140
141 @Override
142 public final MutableFloatForceVector toSparse()
143 {
144 return this.data.isSparse() ? (MutableFloatForceVector) this : instantiateMutableType(this.data.toSparse(), getUnit());
145 }
146
147
148
149
150
151
152 public FloatForce[] toArray()
153 {
154 FloatForce[] array = new FloatForce[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 }