presize collections
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1517418 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40ef9f876c
commit
9c82c679f8
|
@ -361,7 +361,7 @@ public class DSCompiler {
|
|||
|
||||
for (int i = 0; i < dSize; ++i) {
|
||||
final int[][] dRow = derivativeCompiler.multIndirection[i];
|
||||
List<int[]> row = new ArrayList<int[]>();
|
||||
List<int[]> row = new ArrayList<int[]>(dRow.length * 2);
|
||||
for (int j = 0; j < dRow.length; ++j) {
|
||||
row.add(new int[] { dRow[j][0], lowerIndirection[dRow[j][1]], vSize + dRow[j][2] });
|
||||
row.add(new int[] { dRow[j][0], vSize + dRow[j][1], lowerIndirection[dRow[j][2]] });
|
||||
|
|
|
@ -83,7 +83,7 @@ public class MixtureMultivariateNormalDistribution
|
|||
double[][] means,
|
||||
double[][][] covariances) {
|
||||
final List<Pair<Double, MultivariateNormalDistribution>> mvns
|
||||
= new ArrayList<Pair<Double, MultivariateNormalDistribution>>();
|
||||
= new ArrayList<Pair<Double, MultivariateNormalDistribution>>(weights.length);
|
||||
|
||||
for (int i = 0; i < weights.length; i++) {
|
||||
final MultivariateNormalDistribution dist
|
||||
|
|
|
@ -153,7 +153,7 @@ public class MixtureMultivariateRealDistribution<T extends MultivariateRealDistr
|
|||
* @return the component distributions and associated weights.
|
||||
*/
|
||||
public List<Pair<Double, T>> getComponents() {
|
||||
final List<Pair<Double, T>> list = new ArrayList<Pair<Double, T>>();
|
||||
final List<Pair<Double, T>> list = new ArrayList<Pair<Double, T>>(weight.length);
|
||||
|
||||
for (int i = 0; i < weight.length; i++) {
|
||||
list.add(new Pair<Double, T>(weight[i], distribution.get(i)));
|
||||
|
|
|
@ -327,7 +327,7 @@ public class MultivariateNormalMixtureExpectationMaximization {
|
|||
|
||||
// components of mixture model to be created
|
||||
final List<Pair<Double, MultivariateNormalDistribution>> components =
|
||||
new ArrayList<Pair<Double, MultivariateNormalDistribution>>();
|
||||
new ArrayList<Pair<Double, MultivariateNormalDistribution>>(numComponents);
|
||||
|
||||
// create a component based on data in each bin
|
||||
for (int binIndex = 0; binIndex < numComponents; binIndex++) {
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SubLine {
|
|||
public List<Segment> getSegments() {
|
||||
|
||||
final List<Interval> list = remainingRegion.asList();
|
||||
final List<Segment> segments = new ArrayList<Segment>();
|
||||
final List<Segment> segments = new ArrayList<Segment>(list.size());
|
||||
|
||||
for (final Interval interval : list) {
|
||||
final Vector3D start = line.toSpace(new Vector1D(interval.getInf()));
|
||||
|
|
|
@ -186,7 +186,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
}
|
||||
|
||||
// build the edges
|
||||
List<Edge> edges = new ArrayList<Edge>();
|
||||
List<Edge> edges = new ArrayList<Edge>(n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
||||
// get the endpoints of the edge
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
|
||||
final Line line = (Line) getHyperplane();
|
||||
final List<Interval> list = ((IntervalsSet) getRemainingRegion()).asList();
|
||||
final List<Segment> segments = new ArrayList<Segment>();
|
||||
final List<Segment> segments = new ArrayList<Segment>(list.size());
|
||||
|
||||
for (final Interval interval : list) {
|
||||
final Vector2D start = line.toSpace(new Vector1D(interval.getInf()));
|
||||
|
|
|
@ -141,7 +141,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
public Collection<EventHandler> getEventHandlers() {
|
||||
final List<EventHandler> list = new ArrayList<EventHandler>();
|
||||
final List<EventHandler> list = new ArrayList<EventHandler>(eventsStates.size());
|
||||
for (EventState state : eventsStates) {
|
||||
list.add(state.getEventHandler());
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ class SimplexTableau implements Serializable {
|
|||
* @return new versions of the constraints
|
||||
*/
|
||||
public List<LinearConstraint> normalizeConstraints(Collection<LinearConstraint> originalConstraints) {
|
||||
List<LinearConstraint> normalized = new ArrayList<LinearConstraint>();
|
||||
List<LinearConstraint> normalized = new ArrayList<LinearConstraint>(originalConstraints.size());
|
||||
for (LinearConstraint constraint : originalConstraints) {
|
||||
normalized.add(normalize(constraint));
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ class SimplexTableau implements Serializable {
|
|||
* @return new versions of the constraints
|
||||
*/
|
||||
public List<LinearConstraint> normalizeConstraints(Collection<LinearConstraint> originalConstraints) {
|
||||
List<LinearConstraint> normalized = new ArrayList<LinearConstraint>();
|
||||
List<LinearConstraint> normalized = new ArrayList<LinearConstraint>(originalConstraints.size());
|
||||
for (LinearConstraint constraint : originalConstraints) {
|
||||
normalized.add(normalize(constraint));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue