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-2018 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 U; the unit of the new Absolute Mutable FloatAbsoluteTemperatureVector
34       * @param 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; the values of the entries in the new Absolute Mutable FloatAbsoluteTemperatureVector
46       * @param unit U; the unit of the new Absolute Mutable FloatAbsoluteTemperatureVector
47       * @param 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 FloatScalar.Rel&lt;U&gt;[]; the values of the entries in the new Absolute Mutable
59       *            FloatAbsoluteTemperatureVector
60       * @param 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; the values of the entries in the new Absolute Mutable FloatAbsoluteTemperatureVector
72       * @param storageType the data type to use (e.g., DENSE or SPARSE)
73       * @throws ValueException when values has zero entries
74       */
75      public MutableFloatAbsoluteTemperatureVector(final List<FloatAbsoluteTemperature> values, final StorageType storageType)
76              throws ValueException
77      {
78          super(values, storageType);
79      }
80  
81      /**
82       * Construct a new Absolute Mutable FloatAbsoluteTemperatureVector.
83       * @param values FloatScalar.Rel&lt;U&gt;[]; the values of the entries in the new Absolute Sparse Mutable
84       *            FloatAbsoluteTemperatureVector
85       * @param length the size of the vector
86       * @param storageType the data type to use (e.g., DENSE or SPARSE)
87       * @throws ValueException when values has zero entries
88       */
89      public MutableFloatAbsoluteTemperatureVector(final SortedMap<Integer, FloatAbsoluteTemperature> values, final int length,
90              final StorageType storageType) throws ValueException
91      {
92          super(values, length, storageType);
93      }
94  
95      /**
96       * Construct a new Absolute Mutable FloatAbsoluteTemperatureVector.
97       * @param values Map; the map of indexes to values of the Absolute Sparse Mutable FloatAbsoluteTemperatureVector
98       * @param unit U; the unit of the new Absolute Sparse Mutable FloatAbsoluteTemperatureVector
99       * @param length the size of the vector
100      * @param storageType the data type to use (e.g., DENSE or SPARSE)
101      * @throws ValueException when values is null
102      */
103     public MutableFloatAbsoluteTemperatureVector(final SortedMap<Integer, Float> values, final AbsoluteTemperatureUnit unit,
104             final int length, final StorageType storageType) throws ValueException
105     {
106         super(values, unit, length, storageType);
107     }
108 
109     /**
110      * Construct a new Absolute Mutable FloatAbsoluteTemperatureVector.
111      * @param data an internal data object
112      * @param unit the unit
113      */
114     MutableFloatAbsoluteTemperatureVector(final FloatVectorData data, final AbsoluteTemperatureUnit unit)
115     {
116         super(data, unit);
117     }
118 
119     /** {@inheritDoc} */
120     @Override
121     protected final FloatAbsoluteTemperatureVector instantiateTypeAbs(final FloatVectorData dvd,
122             final AbsoluteTemperatureUnit unit)
123     {
124         return new FloatAbsoluteTemperatureVector(dvd, unit);
125     }
126 
127     /** {@inheritDoc} */
128     @Override
129     protected final FloatTemperatureVector instantiateTypeRel(final FloatVectorData dvd, final TemperatureUnit unit)
130     {
131         return new FloatTemperatureVector(dvd, unit);
132     }
133 
134     /** {@inheritDoc} */
135     @Override
136     protected final MutableFloatAbsoluteTemperatureVector instantiateMutableType(final FloatVectorData dvd,
137             final AbsoluteTemperatureUnit unit)
138     {
139         return new MutableFloatAbsoluteTemperatureVector(dvd, unit);
140     }
141 
142     /** {@inheritDoc} */
143     @Override
144     protected final FloatAbsoluteTemperature instantiateScalar(final float value, final AbsoluteTemperatureUnit unit)
145     {
146         return new FloatAbsoluteTemperature(value, unit);
147     }
148 
149     /** {@inheritDoc} */
150     @Override
151     public final MutableFloatAbsoluteTemperatureVector toDense()
152     {
153         return this.data.isDense() ? (MutableFloatAbsoluteTemperatureVector) this
154                 : instantiateMutableType(this.data.toDense(), getUnit());
155     }
156 
157     /** {@inheritDoc} */
158     @Override
159     public final MutableFloatAbsoluteTemperatureVector toSparse()
160     {
161         return this.data.isSparse() ? (MutableFloatAbsoluteTemperatureVector) this
162                 : instantiateMutableType(this.data.toSparse(), getUnit());
163     }
164 
165     /**
166      * Return an array of FloatAbsoluteTemperature Scalars from this vector.
167      * @return FloatAbsoluteTemperature[]; an array of FloatAbsoluteTemperature Scalars from this vector
168      * @throws RuntimeException wrapping a ValueException on error getting one of the values
169      */
170     public FloatAbsoluteTemperature[] toArray()
171     {
172         FloatAbsoluteTemperature[] array = new FloatAbsoluteTemperature[size()];
173         for (int i = 0; i < size(); i++)
174         {
175             try
176             {
177                 array[i] = get(i);
178             }
179             catch (ValueException exception)
180             {
181                 throw new RuntimeException(exception);
182             }
183         }
184         return array;
185     }
186 
187 }