View Javadoc
1   package org.djunits.value.vfloat.vector;
2   
3   import java.util.List;
4   import java.util.SortedMap;
5   
6   import org.djunits.unit.ElectricalResistanceUnit;
7   import org.djunits.value.StorageType;
8   import org.djunits.value.ValueException;
9   import org.djunits.value.vfloat.scalar.FloatElectricalResistance;
10  
11  /**
12   * Mutable Float ElectricalResistanceVector, a vector of values with a ElectricalResistanceUnit.
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 MutableFloatElectricalResistanceVector extends AbstractMutableFloatVectorRel<ElectricalResistanceUnit,
23          FloatElectricalResistanceVector, MutableFloatElectricalResistanceVector, FloatElectricalResistance>
24  {
25      /** */
26      private static final long serialVersionUID = 20151109L;
27  
28      /**
29       * Construct a new Relative Immutable Float ElectricalResistanceVector.
30       * @param values float[]; the values of the entries in the new Relative Immutable Float ElectricalResistanceVector
31       * @param unit ElectricalResistanceUnit; the unit of the new Relative Immutable Float ElectricalResistanceVector
32       * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
33       * @throws ValueException when values is null
34       */
35      public MutableFloatElectricalResistanceVector(final float[] values, final ElectricalResistanceUnit unit,
36              final StorageType storageType) throws ValueException
37      {
38          super(values, unit, storageType);
39      }
40  
41      /**
42       * Construct a new Relative Immutable Float ElectricalResistanceVector.
43       * @param values List&lt;Float&gt;; the values of the entries in the new Relative Immutable Float ElectricalResistanceVector
44       * @param unit ElectricalResistanceUnit; the unit of the new Relative Immutable Float ElectricalResistanceVector
45       * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
46       * @throws ValueException when values is null
47       */
48      public MutableFloatElectricalResistanceVector(final List<Float> values, final ElectricalResistanceUnit unit,
49              final StorageType storageType) throws ValueException
50      {
51          super(values, unit, storageType);
52      }
53  
54      /**
55       * Construct a new Relative Immutable Float ElectricalResistanceVector.
56       * @param values FloatElectricalResistance[]; the values of the entries in the new Relative Immutable Float
57       *            ElectricalResistanceVector
58       * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
59       * @throws ValueException when values has zero entries
60       */
61      public MutableFloatElectricalResistanceVector(final FloatElectricalResistance[] values, final StorageType storageType)
62              throws ValueException
63      {
64          super(values, storageType);
65      }
66  
67      /**
68       * Construct a new Relative Immutable Float ElectricalResistanceVector.
69       * @param values List&lt;FloatElectricalResistance&gt;; the values of the entries in the new Relative Immutable Float
70       *            ElectricalResistanceVector
71       * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
72       * @throws ValueException when values has zero entries
73       */
74      public MutableFloatElectricalResistanceVector(final List<FloatElectricalResistance> values, final StorageType storageType)
75              throws ValueException
76      {
77          super(values, storageType);
78      }
79  
80      /**
81       * Construct a new Relative Immutable Float ElectricalResistanceVector.
82       * @param values SortedMap&lt;Integer, FloatElectricalResistance&gt;; the values of the entries in the new Relative Sparse
83       *            Mutable Float ElectricalResistanceVector
84       * @param length int; the size of the vector
85       * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
86       * @throws ValueException when values has zero entries
87       */
88      public MutableFloatElectricalResistanceVector(final SortedMap<Integer, FloatElectricalResistance> values, final int length,
89              final StorageType storageType) throws ValueException
90      {
91          super(values, length, storageType);
92      }
93  
94      /**
95       * Construct a new Relative Immutable Float ElectricalResistanceVector.
96       * @param values SortedMap&lt;Integer, Float&gt;; the map of indexes to values of the Relative Sparse Mutable Float
97       *            ElectricalResistanceVector
98       * @param unit ElectricalResistanceUnit; the unit of the new Relative Sparse Mutable Float ElectricalResistanceVector
99       * @param length int; the size of the vector
100      * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
101      * @throws ValueException when values is null
102      */
103     public MutableFloatElectricalResistanceVector(final SortedMap<Integer, Float> values, final ElectricalResistanceUnit unit,
104             final int length, final StorageType storageType) throws ValueException
105     {
106         super(values, unit, length, storageType);
107     }
108 
109     /**
110      * @param data FloatVectorData; an internal data object
111      * @param unit ElectricalResistanceUnit; the unit
112      */
113     MutableFloatElectricalResistanceVector(final FloatVectorData data, final ElectricalResistanceUnit unit)
114     {
115         super(data, unit);
116     }
117 
118     /** {@inheritDoc} */
119     @Override
120     protected final FloatElectricalResistanceVector instantiateType(final FloatVectorData dvd,
121             final ElectricalResistanceUnit unit)
122     {
123         return new FloatElectricalResistanceVector(dvd, unit);
124     }
125 
126     /** {@inheritDoc} */
127     @Override
128     protected final MutableFloatElectricalResistanceVector instantiateMutableType(final FloatVectorData dvd,
129             final ElectricalResistanceUnit unit)
130     {
131         return new MutableFloatElectricalResistanceVector(dvd, unit);
132     }
133 
134     /** {@inheritDoc} */
135     @Override
136     protected final FloatElectricalResistance instantiateScalar(final float value, final ElectricalResistanceUnit unit)
137     {
138         return new FloatElectricalResistance(value, unit);
139     }
140 
141     /** {@inheritDoc} */
142     @Override
143     public final MutableFloatElectricalResistanceVector toDense()
144     {
145         return this.data.isDense() ? (MutableFloatElectricalResistanceVector) this
146                 : instantiateMutableType(this.data.toDense(), getUnit());
147     }
148 
149     /** {@inheritDoc} */
150     @Override
151     public final MutableFloatElectricalResistanceVector toSparse()
152     {
153         return this.data.isSparse() ? (MutableFloatElectricalResistanceVector) this
154                 : instantiateMutableType(this.data.toSparse(), getUnit());
155     }
156 
157     /**
158      * Return an array of FloatElectricalResistance Scalars from this vector.
159      * @return FloatElectricalResistance[]; an array of FloatElectricalResistance Scalars from this vector
160      * @throws RuntimeException wrapping a ValueException on error getting one of the values
161      */
162     public FloatElectricalResistance[] toArray()
163     {
164         FloatElectricalResistance[] array = new FloatElectricalResistance[size()];
165         for (int i = 0; i < size(); i++)
166         {
167             try
168             {
169                 array[i] = get(i);
170             }
171             catch (ValueException exception)
172             {
173                 throw new RuntimeException(exception);
174             }
175         }
176         return array;
177     }
178 
179 }