@@ -0,0 +1,2434 @@
+/*%0A * Copyright 2016 Will Knez %3Cwbknez.dev@gmail.com%3E%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.solsticesquared.schelling;%0A%0Aimport sim.util.IntBag;%0A%0A/**%0A * Represents a collection of reusable objects that are intended to be shared%0A * across a single simulation thread.%0A */%0Apublic class ComputeCache %7B%0A%0A    /**%0A     * A collection of default values for a %7B@code ComputeCache%7D.%0A     */%0A    public static final class Defaults %7B%0A%0A        /**%0A         * The default initial capacity to use.%0A         *%0A         * %3Cp%3E%0A         *     This corresponds to a typical %22nearest neighbor%22 grid search with%0A         *     a Moore distance of one without including the search origin.%0A         * %3C/p%3E%0A         */%0A        public static final int InitialCapacity = 8;%0A%0A        /**%0A         * Constructor (private).%0A         */%0A        private Defaults() %7B%0A        %7D%0A    %7D%0A%0A    /**%0A     * The x-axis values that correspond - in order - to the grid cells returned%0A     * from a nearest-neighbor search query.%0A     */%0A    public final IntBag xLocations;%0A%0A    /**%0A     * The x-axis values that correspond - in order - to the grid cells returned%0A     * from a nearest-neighbor search query.%0A     */%0A    public final IntBag yLocations;%0A%0A    /**%0A     * Constructor.%0A     */%0A    public ComputeCache() %7B%0A        this(Defaults.InitialCapacity);%0A    %7D%0A%0A    /**%0A     * Constructor.%0A     *%0A     * @param initialCapacity%0A     *        The number of elements to reserve.%0A     * @throws IllegalArgumentException%0A     *         If %7B@code initialCapacity%7D is less than zero.%0A     */%0A    public ComputeCache(final int initialCapacity) %7B%0A        if(initialCapacity %3C 0) %7B%0A            throw new IllegalArgumentException(%22initial capacity must be %22 +%0A                                               %22positive!%22);%0A        %7D%0A%0A        this.xLocations = new IntBag(initialCapacity);%0A        this.yLocations = new IntBag(initialCapacity);%0A    %7D%0A%7D%0A

Add object to represent a cache of reusable, thread-local data.