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