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.AngleUnit;
7   import org.djunits.unit.DirectionUnit;
8   import org.djunits.unit.scale.IdentityScale;
9   import org.djunits.value.storage.StorageType;
10  import org.djunits.value.vfloat.scalar.FloatAngle;
11  import org.djunits.value.vfloat.scalar.FloatDirection;
12  import org.djunits.value.vfloat.vector.base.FloatVectorAbs;
13  import org.djunits.value.vfloat.vector.data.FloatVectorData;
14  
15  import jakarta.annotation.Generated;
16  
17  /**
18   * Absolute FloatDirection 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 FloatDirectionVector
28          extends FloatVectorAbs<DirectionUnit, FloatDirection, FloatDirectionVector, AngleUnit, FloatAngle, FloatAngleVector>
29  {
30      /** */
31      private static final long serialVersionUID = 20151003L;
32  
33      /**
34       * Construct a FloatDirectionVector from an internal data object.
35       * @param data FloatVectorData; the internal data object for the vector
36       * @param displayUnit DirectionUnit; the display unit of the vector data
37       */
38      public FloatDirectionVector(final FloatVectorData data, final DirectionUnit displayUnit)
39      {
40          super(data, displayUnit);
41      }
42  
43      /* CONSTRUCTORS WITH float[] */
44  
45      /**
46       * Construct a FloatDirectionVector 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 DirectionUnit; 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 FloatDirectionVector(final float[] data, final DirectionUnit displayUnit, final StorageType storageType)
53      {
54          this(FloatVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit);
55      }
56  
57      /**
58       * Construct a FloatDirectionVector from a float[] object. The Float values are expressed in the displayUnit. Assume that
59       * the StorageType is DENSE since we offer the data as an array.
60       * @param data float[]; the data for the vector
61       * @param displayUnit DirectionUnit; the unit of the values in the data array, and display unit when printing
62       */
63      public FloatDirectionVector(final float[] data, final DirectionUnit displayUnit)
64      {
65          this(data, displayUnit, StorageType.DENSE);
66      }
67  
68      /**
69       * Construct a FloatDirectionVector 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 FloatDirectionVector(final float[] data, final StorageType storageType)
74      {
75          this(data, DirectionUnit.DEFAULT, storageType);
76      }
77  
78      /**
79       * Construct a FloatDirectionVector 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 FloatDirectionVector(final float[] data)
84      {
85          this(data, StorageType.DENSE);
86      }
87  
88      /* CONSTRUCTORS WITH FloatDirection[] */
89  
90      /**
91       * Construct a FloatDirectionVector from an array of FloatDirection objects. The FloatDirection values are each expressed in
92       * their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing.
93       * @param data FloatDirection[]; the data for the vector
94       * @param displayUnit DirectionUnit; 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 FloatDirectionVector(final FloatDirection[] data, final DirectionUnit displayUnit, final StorageType storageType)
98      {
99          this(FloatVectorData.instantiate(data, storageType), displayUnit);
100     }
101 
102     /**
103      * Construct a FloatDirectionVector from an array of FloatDirection objects. The FloatDirection values are each expressed in
104      * their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. Assume that
105      * the StorageType is DENSE since we offer the data as an array.
106      * @param data FloatDirection[]; the data for the vector
107      * @param displayUnit DirectionUnit; the display unit of the values when printing
108      */
109     public FloatDirectionVector(final FloatDirection[] data, final DirectionUnit displayUnit)
110     {
111         this(data, displayUnit, StorageType.DENSE);
112     }
113 
114     /**
115      * Construct a FloatDirectionVector from an array of FloatDirection objects. The FloatDirection values are each expressed in
116      * their own unit, but will be internally stored as SI values, and expressed using SI units when printing. since we offer
117      * the data as an array.
118      * @param data FloatDirection[]; the data for the vector
119      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
120      */
121     public FloatDirectionVector(final FloatDirection[] data, final StorageType storageType)
122     {
123         this(data, DirectionUnit.DEFAULT, storageType);
124     }
125 
126     /**
127      * Construct a FloatDirectionVector from an array of FloatDirection objects. The FloatDirection values are each expressed in
128      * their 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 FloatDirection[]; the data for the vector
131      */
132     public FloatDirectionVector(final FloatDirection[] data)
133     {
134         this(data, StorageType.DENSE);
135     }
136 
137     /* CONSTRUCTORS WITH List<Float> or List<Direction> */
138 
139     /**
140      * Construct a FloatDirectionVector from a list of Number objects or a list of FloatDirection objects. Note that the
141      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or
142      * FloatDirection objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values
143      * in the list are expressed, as well as the unit in which they will be printed. In case the list contains FloatDirection
144      * objects, each FloatDirection has its own unit, and the displayUnit is just used for printing. The values but will always
145      * be internally 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;Direction&gt;; the data for the vector
147      * @param displayUnit DirectionUnit; 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 FloatDirectionVector(final List<? extends Number> data, final DirectionUnit displayUnit,
152             final StorageType storageType)
153     {
154         this(data.size() == 0 ? FloatVectorData.instantiate(new float[] {}, IdentityScale.SCALE, storageType)
155                 : data.get(0) instanceof FloatDirection ? FloatVectorData.instantiate(data, IdentityScale.SCALE, storageType)
156                         : FloatVectorData.instantiate(data, displayUnit.getScale(), storageType),
157                 displayUnit);
158     }
159 
160     /**
161      * Construct a FloatDirectionVector from a list of Number objects or a list of FloatDirection objects. Note that the
162      * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or
163      * FloatDirection objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values
164      * in the list are expressed, as well as the unit in which they will be printed. In case the list contains FloatDirection
165      * objects, each FloatDirection has its own unit, and the displayUnit is just used for printing. The values but will always
166      * be internally stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume
167      * the storage type is DENSE since we offer the data as a List.
168      * @param data List&lt;Float&gt; or List&lt;Direction&gt;; the data for the vector
169      * @param displayUnit DirectionUnit; the display unit of the vector data, and the unit of the data points when the data is
170      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
171      */
172     public FloatDirectionVector(final List<? extends Number> data, final DirectionUnit displayUnit)
173     {
174         this(data, displayUnit, StorageType.DENSE);
175     }
176 
177     /**
178      * Construct a FloatDirectionVector from a list of Number objects or a list of FloatDirection objects. When data contains
179      * numbers such as Float, assume that they are expressed using SI units. When the data consists of FloatDirection objects,
180      * they each have their own unit, but will be printed using SI units or base units. The values but will always be internally
181      * stored as SI values or base values, and expressed using the display unit or base unit when printing.
182      * @param data List&lt;Float&gt; or List&lt;Direction&gt;; the data for the vector
183      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
184      */
185     public FloatDirectionVector(final List<? extends Number> data, final StorageType storageType)
186     {
187         this(data, DirectionUnit.DEFAULT, storageType);
188     }
189 
190     /**
191      * Construct a FloatDirectionVector from a list of Number objects or a list of FloatDirection objects. When data contains
192      * numbers such as Float, assume that they are expressed using SI units. When the data consists of FloatDirection objects,
193      * they each have their own unit, but will be printed using SI units or base units. The values but will always be internally
194      * stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage
195      * type is DENSE since we offer the data as a List.
196      * @param data List&lt;Float&gt; or List&lt;Direction&gt;; the data for the vector
197      */
198     public FloatDirectionVector(final List<? extends Number> data)
199     {
200         this(data, StorageType.DENSE);
201     }
202 
203     /* CONSTRUCTORS WITH Map<Integer, Float> or Map<Integer, FloatDirection> */
204 
205     /**
206      * Construct a FloatDirectionVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
207      * to of FloatDirection objects. Using index values is particularly useful for sparse vectors. The size parameter indicates
208      * the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
209      * different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatDirection objects.
210      * In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed,
211      * as well as the unit in which they will be printed. In case the map contains FloatDirection objects, each FloatDirection
212      * has its own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI
213      * values or base values, and expressed using the display unit or base unit when printing.
214      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatDirection&gt;; the data for the vector
215      * @param size int; the size off the vector, i.e., the highest index
216      * @param displayUnit DirectionUnit; the display unit of the vector data, and the unit of the data points when the data is
217      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
218      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
219      */
220     public FloatDirectionVector(final Map<Integer, ? extends Number> data, final int size, final DirectionUnit displayUnit,
221             final StorageType storageType)
222     {
223         this(data.size() == 0 ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
224                 : data.values().iterator().next() instanceof FloatDirection
225                         ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType)
226                         : FloatVectorData.instantiate(data, size, displayUnit.getScale(), storageType),
227                 displayUnit);
228     }
229 
230     /**
231      * Construct a FloatDirectionVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
232      * to of FloatDirection objects. Using index values is particularly useful for sparse vectors. The size parameter indicates
233      * the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a
234      * different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatDirection objects.
235      * In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed,
236      * as well as the unit in which they will be printed. In case the map contains FloatDirection objects, each FloatDirection
237      * has its own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI
238      * values or base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE
239      * since we offer the data as a Map.
240      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatDirection&gt;; the data for the vector
241      * @param size int; the size off the vector, i.e., the highest index
242      * @param displayUnit DirectionUnit; the display unit of the vector data, and the unit of the data points when the data is
243      *            expressed as List&lt;Float&gt; or List&lt;Number&gt; in general
244      */
245     public FloatDirectionVector(final Map<Integer, ? extends Number> data, final int size, final DirectionUnit displayUnit)
246     {
247         this(data, size, displayUnit, StorageType.SPARSE);
248     }
249 
250     /**
251      * Construct a FloatDirectionVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
252      * to of FloatDirection objects. Using index values is particularly useful for sparse vectors. The size parameter indicates
253      * the size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
254      * Float, assume that they are expressed using SI units. When the data consists of FloatDirection objects, they each have
255      * their own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI
256      * values or base values, and expressed using the display unit or base unit when printing.
257      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatDirection&gt;; the data for the vector
258      * @param size int; the size off the vector, i.e., the highest index
259      * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector
260      */
261     public FloatDirectionVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType)
262     {
263         this(data, size, DirectionUnit.DEFAULT, storageType);
264     }
265 
266     /**
267      * Construct a FloatDirectionVector from a (sparse) map of index values to Number objects or a (sparse) map of index values
268      * to of FloatDirection objects. Using index values is particularly useful for sparse vectors. The size parameter indicates
269      * the size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as
270      * Float, assume that they are expressed using SI units. When the data consists of FloatDirection objects, they each have
271      * their own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI
272      * values or base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE
273      * since we offer the data as a Map.
274      * @param data Map&lt;Integer, Float&gt; or Map&lt;Integer, FloatDirection&gt;; the data for the vector
275      * @param size int; the size off the vector, i.e., the highest index
276      */
277     public FloatDirectionVector(final Map<Integer, ? extends Number> data, final int size)
278     {
279         this(data, size, StorageType.SPARSE);
280     }
281 
282     /* ****************************** Other methods ****************************** */
283 
284     @Override
285     public Class<FloatDirection>
286 
287             getScalarClass()
288     {
289         return FloatDirection.class;
290     }
291 
292     @Override
293     public FloatDirectionVector instantiateVector(final FloatVectorData fvd, final DirectionUnit displayUnit)
294     {
295         return new FloatDirectionVector(fvd, displayUnit);
296     }
297 
298     @Override
299     public FloatDirection instantiateScalarSI(final float valueSI, final DirectionUnit displayUnit)
300     {
301         FloatDirection result = FloatDirection.instantiateSI(valueSI);
302         result.setDisplayUnit(displayUnit);
303         return result;
304     }
305 
306     @Override
307     public FloatAngleVector instantiateVectorRel(final FloatVectorData fvd, final AngleUnit displayUnit)
308     {
309         return new FloatAngleVector(fvd, displayUnit);
310     }
311 
312     @Override
313     public FloatAngle instantiateScalarRelSI(final float valueSI, final AngleUnit displayUnit)
314     {
315         FloatAngle result = FloatAngle.instantiateSI(valueSI);
316         result.setDisplayUnit(displayUnit);
317         return result;
318     }
319 
320 }