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