View Javadoc
1   package org.djunits.value.vfloat.vector;
2   
3   import java.util.List;
4   import java.util.Map;
5   
6   import org.djunits.unit.LengthUnit;
7   import org.djunits.unit.PositionUnit;
8   import org.djunits.unit.scale.IdentityScale;
9   import org.djunits.value.storage.StorageType;
10  import org.djunits.value.vfloat.scalar.FloatLength;
11  import org.djunits.value.vfloat.scalar.FloatPosition;
12  import org.djunits.value.vfloat.vector.base.FloatVectorRelWithAbs;
13  import org.djunits.value.vfloat.vector.data.FloatVectorData;
14  
15  import jakarta.annotation.Generated;
16  
17  /**
18   * Relative FloatLength Vector.
19   * <p>
20   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
21   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
22   * </p>
23   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
24   * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a>
25   */
26  @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
27  public class FloatLengthVector extends
28          FloatVectorRelWithAbs<PositionUnit, FloatPosition, FloatPositionVector, LengthUnit, FloatLength, FloatLengthVector>
29  {
30      /** */
31      private static final long serialVersionUID = 20151006L;
32  
33      /**
34       * Construct a FloatLengthVector from an internal data object.
35       * @param data FloatVectorData; the internal data object for the vector
36       * @param displayUnit LengthUnit; the display unit of the vector data
37       */
38      public FloatLengthVector(final FloatVectorData data, final LengthUnit displayUnit)
39      {
40          super(data, displayUnit);
41      }
42  
43      /* CONSTRUCTORS WITH float[] */
44  
45      /**
46       * Construct a FloatLengthVector from a float[] object. The Float values are expressed in the displayUnit, and will be
47       * printed using the displayUnit.
48       * @param data float[]; the data for the vector, expressed in the displayUnit
49       * @param displayUnit LengthUnit; the unit of the values in the data array, and display unit when printing
50       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
51       */
52      public FloatLengthVector(final float[] data, final LengthUnit displayUnit, final StorageType storageType)
53      {
54          this(FloatVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
55      }
56  
57      /**
58       * Construct a FloatLengthVector from a float[] object. The Float values are expressed in the displayUnit. Assume that the
59       * StorageType is DENSE since we offer the data as an array.
60       * @param data float[]; the data for the vector
61       * @param displayUnit LengthUnit; the unit of the values in the data array, and display unit when printing
62       */
63      public FloatLengthVector(final float[] data, final LengthUnit displayUnit)
64      {
65          this(data, displayUnit, StorageType.DENSE);
66      }
67  
68      /**
69       * Construct a FloatLengthVector from a float[] object with SI-unit values.
70       * @param data float[]; the data for the vector, in SI units
71       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
72       */
73      public FloatLengthVector(final float[] data, final StorageType storageType)
74      {
75          this(data, LengthUnit.SI, storageType);
76      }
77  
78      /**
79       * Construct a FloatLengthVector from a float[] object with SI-unit values. Assume that the StorageType is DENSE since we
80       * offer the data as an array.
81       * @param data float[]; the data for the vector, in SI units
82       */
83      public FloatLengthVector(final float[] data)
84      {
85          this(data, StorageType.DENSE);
86      }
87  
88      /* CONSTRUCTORS WITH FloatLength[] */
89  
90      /**
91       * Construct a FloatLengthVector from an array of FloatLength objects. The FloatLength values are each expressed in their
92       * own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
93       * @param data FloatLength[]; the data for the vector
94       * @param displayUnit LengthUnit; the display unit of the values when printing
95       * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
96       */
97      public FloatLengthVector(final FloatLength[] data, final LengthUnit displayUnit, final StorageType storageType)
98      {
99          this(FloatVectorData.instantiate(data, storageType), displayUnit);
100     }
101 
102     /**
103      * Construct a FloatLengthVector from an array of FloatLength objects. The FloatLength values are each expressed in their
104      * own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. Assume that the
105      * StorageType is DENSE since we offer the data as an array.
106      * @param data FloatLength[]; the data for the vector
107      * @param displayUnit LengthUnit; the display unit of the values when printing
108      */
109     public FloatLengthVector(final FloatLength[] data, final LengthUnit displayUnit)
110     {
111         this(data, displayUnit, StorageType.DENSE);
112     }
113 
114     /**
115      * Construct a FloatLengthVector from an array of FloatLength objects. The FloatLength values are each expressed in their
116      * own unit, but will be internally stored as SI values, and expressed using SI units when printing. since we offer the data
117      * as an array.
118      * @param data FloatLength[]; the data for the vector
119      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
120      */
121     public FloatLengthVector(final FloatLength[] data, final StorageType storageType)
122     {
123         this(data, LengthUnit.SI, storageType);
124     }
125 
126     /**
127      * Construct a FloatLengthVector from an array of FloatLength objects. The FloatLength values are each expressed in their
128      * own unit, but will be internally stored as SI values, and expressed using SI units when printing. Assume that the
129      * StorageType is DENSE since we offer the data as an array.
130      * @param data FloatLength[]; the data for the vector
131      */
132     public FloatLengthVector(final FloatLength[] data)
133     {
134         this(data, StorageType.DENSE);
135     }
136 
137     /* CONSTRUCTORS WITH List<Float> or List<Length> */
138 
139     /**
140      * Construct a FloatLengthVector from a list of Number objects or a list of FloatLength objects. Note that the displayUnit
141      * has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or FloatLength
142      * objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values in the list are
143      * expressed, as well as the unit in which they will be printed. In case the list contains FloatLength objects, each
144      * FloatLength has its own unit, and the displayUnit is just used for printing. The values but will always be internally
145      * stored as SI values or base values, and expressed using the display unit or base unit when printing.
146      * @param data List&lt;Float&gt; or List&lt;Length&gt;; the data for the vector
147      * @param displayUnit LengthUnit; the display unit of the vector data, and the unit of the data points when the data is
148      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
149      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
150      */
151     public FloatLengthVector(final List<? extends Number> data, final LengthUnit displayUnit, final StorageType storageType)
152     {
153         this(data.size() == 0 ? FloatVectorData.instantiate(new float[] {}, IdentityScale.SCALE, storageType)
154                 : data.get(0) instanceof FloatLength ? FloatVectorData.instantiate(data, IdentityScale.SCALE, storageType)
155                         : FloatVectorData.instantiate(data, displayUnit.getScale(), storageType),
156                 displayUnit);
157     }
158 
159     /**
160      * Construct a FloatLengthVector from a list of Number objects or a list of FloatLength objects. Note that the displayUnit
161      * has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or FloatLength
162      * objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values in the list are
163      * expressed, as well as the unit in which they will be printed. In case the list contains FloatLength objects, each
164      * FloatLength has its own unit, and the displayUnit is just used for printing. The values but will always be internally
165      * stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage
166      * type is DENSE since we offer the data as a List.
167      * @param data List&lt;Float&gt; or List&lt;Length&gt;; the data for the vector
168      * @param displayUnit LengthUnit; the display unit of the vector data, and the unit of the data points when the data is
169      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
170      */
171     public FloatLengthVector(final List<? extends Number> data, final LengthUnit displayUnit)
172     {
173         this(data, displayUnit, StorageType.DENSE);
174     }
175 
176     /**
177      * Construct a FloatLengthVector from a list of Number objects or a list of FloatLength objects. When data contains numbers
178      * such as Float, assume that they are expressed using SI units. When the data consists of FloatLength objects, they each
179      * have their own unit, but will be printed using SI units or base units. The values but will always be internally stored as
180      * SI values or base values, and expressed using the display unit or base unit when printing.
181      * @param data List&lt;Float&gt; or List&lt;Length&gt;; the data for the vector
182      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
183      */
184     public FloatLengthVector(final List<? extends Number> data, final StorageType storageType)
185     {
186         this(data, LengthUnit.SI, storageType);
187     }
188 
189     /**
190      * Construct a FloatLengthVector from a list of Number objects or a list of FloatLength objects. When data contains numbers
191      * such as Float, assume that they are expressed using SI units. When the data consists of FloatLength objects, they each
192      * have their own unit, but will be printed using SI units or base units. The values but will always be internally stored as
193      * SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage type is
194      * DENSE since we offer the data as a List.
195      * @param data List&lt;Float&gt; or List&lt;Length&gt;; the data for the vector
196      */
197     public FloatLengthVector(final List<? extends Number> data)
198     {
199         this(data, StorageType.DENSE);
200     }
201 
202     /* CONSTRUCTORS WITH Map<Integer, Float> or Map<Integer, FloatLength> */
203 
204     /**
205      * Construct a FloatLengthVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
206      * of FloatLength objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
207      * size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
208      * different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatLength objects. In
209      * case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as
210      * well as the unit in which they will be printed. In case the map contains FloatLength objects, each FloatLength has its
211      * own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or
212      * base values, and expressed using the display unit or base unit when printing.
213      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatLength&gt;; the data for the vector
214      * @param size int; the size off the vector, i.e., the highest index
215      * @param displayUnit LengthUnit; the display unit of the vector data, and the unit of the data points when the data is
216      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
217      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
218      */
219     public FloatLengthVector(final Map<Integer, ? extends Number> data, final int size, final LengthUnit displayUnit,
220             final StorageType storageType)
221     {
222         this(data.size() == 0 ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
223                 : data.values().iterator().next() instanceof FloatLength
224                         ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
225                         : FloatVectorData.instantiate(data, size, displayUnit.getScale(), storageType),
226                 displayUnit);
227     }
228 
229     /**
230      * Construct a FloatLengthVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
231      * of FloatLength objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
232      * size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
233      * different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatLength objects. In
234      * case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as
235      * well as the unit in which they will be printed. In case the map contains FloatLength objects, each FloatLength has its
236      * own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI values or
237      * base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since we
238      * offer the data as a Map.
239      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatLength&gt;; the data for the vector
240      * @param size int; the size off the vector, i.e., the highest index
241      * @param displayUnit LengthUnit; the display unit of the vector data, and the unit of the data points when the data is
242      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
243      */
244     public FloatLengthVector(final Map<Integer, ? extends Number> data, final int size, final LengthUnit displayUnit)
245     {
246         this(data, size, displayUnit, StorageType.SPARSE);
247     }
248 
249     /**
250      * Construct a FloatLengthVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
251      * of FloatLength objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
252      * size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
253      * Float, assume that they are expressed using SI units. When the data consists of FloatLength objects, they each have their
254      * own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI values
255      * or base values, and expressed using the display unit or base unit when printing.
256      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatLength&gt;; the data for the vector
257      * @param size int; the size off the vector, i.e., the highest index
258      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
259      */
260     public FloatLengthVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType)
261     {
262         this(data, size, LengthUnit.SI, storageType);
263     }
264 
265     /**
266      * Construct a FloatLengthVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to
267      * of FloatLength objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the
268      * size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
269      * Float, assume that they are expressed using SI units. When the data consists of FloatLength objects, they each have their
270      * own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI values
271      * or base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since
272      * we offer the data as a Map.
273      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatLength&gt;; the data for the vector
274      * @param size int; the size off the vector, i.e., the highest index
275      */
276     public FloatLengthVector(final Map<Integer, ? extends Number> data, final int size)
277     {
278         this(data, size, StorageType.SPARSE);
279     }
280 
281     /* ****************************** Other methods ****************************** */
282 
283     @Override
284     public Class<FloatLength> getScalarClass()
285     {
286         return FloatLength.class;
287     }
288 
289     @Override
290     public FloatLengthVector instantiateVector(final FloatVectorData fvd, final LengthUnit displayUnit)
291     {
292         return new FloatLengthVector(fvd, displayUnit);
293     }
294 
295     @Override
296     public FloatLength instantiateScalarSI(final float valueSI, final LengthUnit displayUnit)
297     {
298         FloatLength result = FloatLength.instantiateSI(valueSI);
299         result.setDisplayUnit(displayUnit);
300         return result;
301     }
302 
303     @Override
304     public FloatPositionVector instantiateVectorAbs(final FloatVectorData fvd, final PositionUnit displayUnit)
305     {
306         return new FloatPositionVector(fvd, displayUnit);
307     }
308 
309     @Override
310     public FloatPosition instantiateScalarAbsSI(final float valueSI, final PositionUnit displayUnit)
311     {
312         FloatPosition result = FloatPosition.instantiateSI(valueSI);
313         result.setDisplayUnit(displayUnit);
314         return result;
315     }
316 
317 }