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