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