All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbox2d.pooling.arrays.GeneratorArray Maven / Gradle / Ivy

package org.jbox2d.pooling.arrays;

import java.util.HashMap;

import org.jbox2d.particle.VoronoiDiagram;

public class GeneratorArray {

  private final HashMap map =
      new HashMap();

  public VoronoiDiagram.Generator[] get(int length) {
    assert (length > 0);

    if (!map.containsKey(length)) {
      map.put(length, getInitializedArray(length));
    }

    assert (map.get(length).length == length) : "Array not built of correct length";
    return map.get(length);
  }

  protected VoronoiDiagram.Generator[] getInitializedArray(int length) {
    final VoronoiDiagram.Generator[] ray = new VoronoiDiagram.Generator[length];
    for (int i = 0; i < ray.length; i++) {
      ray[i] = new VoronoiDiagram.Generator();
    }
    return ray;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy