1 package org.djunits.value.vfloat.vector; 2 3 import java.util.List; 4 import java.util.SortedMap; 5 6 import org.djunits.unit.ElectricalCurrentUnit; 7 import org.djunits.value.StorageType; 8 import org.djunits.value.ValueException; 9 import org.djunits.value.vfloat.scalar.FloatElectricalCurrent; 10 11 /** 12 * Immutable Float FloatElectricalCurrentVector, a vector of values with a ElectricalCurrentUnit. 13 * <p> 14 * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 15 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 16 * </p> 17 * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, 18 * initial version Oct 9, 2015 <br> 19 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 20 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 21 */ 22 public class FloatElectricalCurrentVector extends AbstractFloatVectorRel<ElectricalCurrentUnit, FloatElectricalCurrentVector, 23 MutableFloatElectricalCurrentVector, FloatElectricalCurrent> 24 { 25 /** */ 26 private static final long serialVersionUID = 20151109L; 27 28 /** 29 * Construct a new Relative Immutable Float FloatElectricalCurrentVector. 30 * @param values float[]; the values of the entries in the new Relative Immutable Float FloatElectricalCurrentVector 31 * @param unit ElectricalCurrentUnit; the unit of the new Relative Immutable Float FloatElectricalCurrentVector 32 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 33 * @throws ValueException when values is null 34 */ 35 public FloatElectricalCurrentVector(final float[] values, final ElectricalCurrentUnit unit, final StorageType storageType) 36 throws ValueException 37 { 38 super(values, unit, storageType); 39 } 40 41 /** 42 * Construct a new Relative Immutable Float FloatElectricalCurrentVector. 43 * @param values List<Float>; the values of the entries in the new Relative Immutable Float 44 * FloatElectricalCurrentVector 45 * @param unit ElectricalCurrentUnit; the unit of the new Relative Immutable Float FloatElectricalCurrentVector 46 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 47 * @throws ValueException when values is null 48 */ 49 public FloatElectricalCurrentVector(final List<Float> values, final ElectricalCurrentUnit unit, 50 final StorageType storageType) throws ValueException 51 { 52 super(values, unit, storageType); 53 } 54 55 /** 56 * Construct a new Relative Immutable Float FloatElectricalCurrentVector. 57 * @param values FloatElectricalCurrent[]; the values of the entries in the new Relative Immutable Float 58 * FloatElectricalCurrentVector 59 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 60 * @throws ValueException when values has zero entries 61 */ 62 public FloatElectricalCurrentVector(final FloatElectricalCurrent[] values, final StorageType storageType) 63 throws ValueException 64 { 65 super(values, storageType); 66 } 67 68 /** 69 * Construct a new Relative Immutable Float FloatElectricalCurrentVector. 70 * @param values List<FloatElectricalCurrent>; the values of the entries in the new Relative Immutable Float 71 * FloatElectricalCurrentVector 72 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 73 * @throws ValueException when values has zero entries 74 */ 75 public FloatElectricalCurrentVector(final List<FloatElectricalCurrent> values, final StorageType storageType) 76 throws ValueException 77 { 78 super(values, storageType); 79 } 80 81 /** 82 * Construct a new Relative Immutable Float FloatElectricalCurrentVector. 83 * @param values SortedMap<Integer, FloatElectricalCurrent>; the values of the entries in the new Relative Sparse 84 * Mutable Float FloatElectricalCurrentVector 85 * @param length int; the size of the vector 86 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 87 * @throws ValueException when values has zero entries 88 */ 89 public FloatElectricalCurrentVector(final SortedMap<Integer, FloatElectricalCurrent> values, final int length, 90 final StorageType storageType) throws ValueException 91 { 92 super(values, length, storageType); 93 } 94 95 /** 96 * Construct a new Relative Immutable Float FloatElectricalCurrentVector. 97 * @param values SortedMap<Integer, Float>; the map of indexes to values of the Relative Sparse Mutable Float 98 * FloatElectricalCurrentVector 99 * @param unit ElectricalCurrentUnit; the unit of the new Relative Sparse Mutable Float FloatElectricalCurrentVector 100 * @param length int; the size of the vector 101 * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE) 102 * @throws ValueException when values is null 103 */ 104 public FloatElectricalCurrentVector(final SortedMap<Integer, Float> values, final ElectricalCurrentUnit unit, 105 final int length, final StorageType storageType) throws ValueException 106 { 107 super(values, unit, length, storageType); 108 } 109 110 /** 111 * @param data FloatVectorData; an internal data object 112 * @param unit ElectricalCurrentUnit; the unit 113 */ 114 FloatElectricalCurrentVector(final FloatVectorData data, final ElectricalCurrentUnit unit) 115 { 116 super(data, unit); 117 } 118 119 /** {@inheritDoc} */ 120 @Override 121 protected final FloatElectricalCurrentVector instantiateType(final FloatVectorData dvd, final ElectricalCurrentUnit unit) 122 { 123 return new FloatElectricalCurrentVector(dvd, unit); 124 } 125 126 /** {@inheritDoc} */ 127 @Override 128 protected final MutableFloatElectricalCurrentVector instantiateMutableType(final FloatVectorData dvd, 129 final ElectricalCurrentUnit unit) 130 { 131 return new MutableFloatElectricalCurrentVector(dvd, unit); 132 } 133 134 /** {@inheritDoc} */ 135 @Override 136 protected final FloatElectricalCurrent instantiateScalar(final float value, final ElectricalCurrentUnit unit) 137 { 138 return new FloatElectricalCurrent(value, unit); 139 } 140 141 /** {@inheritDoc} */ 142 @Override 143 public final FloatElectricalCurrentVector toDense() 144 { 145 return this.data.isDense() ? (FloatElectricalCurrentVector) this : instantiateType(this.data.toDense(), getUnit()); 146 } 147 148 /** {@inheritDoc} */ 149 @Override 150 public final FloatElectricalCurrentVector toSparse() 151 { 152 return this.data.isSparse() ? (FloatElectricalCurrentVector) this : instantiateType(this.data.toSparse(), getUnit()); 153 } 154 155 /** 156 * Return an array of FloatElectricalCurrent Scalars from this vector. 157 * @return FloatElectricalCurrent[]; an array of FloatElectricalCurrent Scalars from this vector 158 * @throws RuntimeException wrapping a ValueException on error getting one of the values 159 */ 160 public FloatElectricalCurrent[] toArray() 161 { 162 FloatElectricalCurrent[] array = new FloatElectricalCurrent[size()]; 163 for (int i = 0; i < size(); i++) 164 { 165 try 166 { 167 array[i] = get(i); 168 } 169 catch (ValueException exception) 170 { 171 throw new RuntimeException(exception); 172 } 173 } 174 return array; 175 } 176 177 }