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