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-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 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 AbsoluteTemperatureUnit; the unit of the new Absolute Immutable Double AbsoluteTemperatureVector
33       * @param storageType 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&lt;Double&gt;; the values of the entries in the new Absolute Immutable Double
45       *            AbsoluteTemperatureVector
46       * @param unit AbsoluteTemperatureUnit; the unit of the new Absolute Immutable Double AbsoluteTemperatureVector
47       * @param storageType StorageType; the data type to use (e.g., DENSE or SPARSE)
48       * @throws ValueException when values is null
49       */
50      public AbsoluteTemperatureVector(final List<Double> values, final AbsoluteTemperatureUnit unit,
51              final StorageType storageType) throws ValueException
52      {
53          super(values, unit, storageType);
54      }
55  
56      /**
57       * Construct a new Absolute Immutable Double AbsoluteTemperatureVector.
58       * @param values AbsoluteTemperature[]; the values of the entries in the new Absolute Immutable Double
59       *            AbsoluteTemperatureVector
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 AbsoluteTemperatureVector(final AbsoluteTemperature[] values, final StorageType storageType) throws ValueException
64      {
65          super(values, storageType);
66      }
67  
68      /**
69       * Construct a new Absolute Immutable Double AbsoluteTemperatureVector.
70       * @param values List&lt;AbsoluteTemperature&gt;; the values of the entries in the new Absolute Immutable Double
71       *            AbsoluteTemperatureVector
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 AbsoluteTemperatureVector(final List<AbsoluteTemperature> values, final StorageType storageType)
76              throws ValueException
77      {
78          super(values, storageType);
79      }
80  
81      /**
82       * Construct a new Absolute Immutable Double AbsoluteTemperatureVector.
83       * @param values SortedMap&lt;Integer, AbsoluteTemperature&gt;; the values of the entries in the new Absolute Sparse Mutable
84       *            Double AbsoluteTemperatureVector
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 AbsoluteTemperatureVector(final SortedMap<Integer, AbsoluteTemperature> values, final int length,
90              final StorageType storageType) throws ValueException
91      {
92          super(values, length, storageType);
93      }
94  
95      /**
96       * Construct a new Absolute Immutable Double AbsoluteTemperatureVector.
97       * @param values SortedMap&lt;Integer, Double&gt;; the map of indexes to values of the Absolute Sparse Mutable Double
98       *            AbsoluteTemperatureVector
99       * @param unit AbsoluteTemperatureUnit; the unit of the new Absolute Sparse Mutable Double AbsoluteTemperatureVector
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 AbsoluteTemperatureVector(final SortedMap<Integer, Double> values, final AbsoluteTemperatureUnit unit,
105             final int length, final StorageType storageType) throws ValueException
106     {
107         super(values, unit, length, storageType);
108     }
109 
110     /**
111      * Construct a new Absolute Immutable Double AbsoluteTemperatureVector.
112      * @param data DoubleVectorData; an internal data object
113      * @param unit AbsoluteTemperatureUnit; the unit
114      */
115     AbsoluteTemperatureVector(final DoubleVectorData data, final AbsoluteTemperatureUnit unit)
116     {
117         super(data, unit);
118     }
119 
120     /** {@inheritDoc} */
121     @Override
122     protected final AbsoluteTemperatureVector instantiateTypeAbs(final DoubleVectorData dvd, final AbsoluteTemperatureUnit unit)
123     {
124         return new AbsoluteTemperatureVector(dvd, unit);
125     }
126 
127     /** {@inheritDoc} */
128     @Override
129     protected final TemperatureVector instantiateTypeRel(final DoubleVectorData dvd, final TemperatureUnit unit)
130     {
131         return new TemperatureVector(dvd, unit);
132     }
133 
134     /** {@inheritDoc} */
135     @Override
136     protected final MutableAbsoluteTemperatureVector instantiateMutableType(final DoubleVectorData dvd,
137             final AbsoluteTemperatureUnit unit)
138     {
139         return new MutableAbsoluteTemperatureVector(dvd, unit);
140     }
141 
142     /** {@inheritDoc} */
143     @Override
144     protected final AbsoluteTemperature instantiateScalar(final double value, final AbsoluteTemperatureUnit unit)
145     {
146         return new AbsoluteTemperature(value, unit);
147     }
148 
149     /** {@inheritDoc} */
150     @Override
151     public final AbsoluteTemperatureVector toDense()
152     {
153         return this.data.isDense() ? (AbsoluteTemperatureVector) this : instantiateTypeAbs(this.data.toDense(), getUnit());
154     }
155 
156     /** {@inheritDoc} */
157     @Override
158     public final AbsoluteTemperatureVector toSparse()
159     {
160         return this.data.isSparse() ? (AbsoluteTemperatureVector) this : instantiateTypeAbs(this.data.toSparse(), getUnit());
161     }
162 
163     /**
164      * Return an array of AbsoluteTemperature Scalars from this vector.
165      * @return AbsoluteTemperature[]; an array of AbsoluteTemperature Scalars from this vector
166      * @throws RuntimeException wrapping a ValueException on error getting one of the values
167      */
168     public AbsoluteTemperature[] toArray()
169     {
170         AbsoluteTemperature[] array = new AbsoluteTemperature[size()];
171         for (int i = 0; i < size(); i++)
172         {
173             try
174             {
175                 array[i] = get(i);
176             }
177             catch (ValueException exception)
178             {
179                 throw new RuntimeException(exception);
180             }
181         }
182         return array;
183     }
184 
185 }