@@ -0,0 +1,3387 @@
+/*%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.engine.RandomSequence;%0Aimport sim.engine.Steppable;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0A%0A/**%0A * Represents an implementation of a %7B@link RandomSequence%7D whose collection of%0A * agents may be removed, or cleared, and therefore a single instance is able to%0A * be reused in an arbitrary number of simulation runs.%0A */%0Apublic class ClearableRandomSequence extends RandomSequence %7B%0A%0A    /**%0A     * Constructor.%0A     */%0A    public ClearableRandomSequence() %7B%0A        super(new ArrayList%3C%3E(0), false);%0A    %7D%0A%0A    /**%0A     * Constructor.%0A     *%0A     * @param agents%0A     *        The initial array of agents to use.%0A     */%0A    public ClearableRandomSequence(final Steppable%5B%5D agents) %7B%0A        super(agents, false);%0A        this.setUsesSets(true);%0A    %7D%0A%0A    /**%0A     * Constructor.%0A     *%0A     * @param collection%0A     *        The initial collection of agents to use.%0A     */%0A    public ClearableRandomSequence(final Collection%3CSteppable%3E collection) %7B%0A        super(collection, false);%0A        this.setUsesSets(true);%0A    %7D%0A%0A    /**%0A     * Constructor.%0A     *%0A     * @param agents%0A     *        The initial array of agents to use.%0A     * @param shouldSynchronize%0A     *        Whether or not to synchronize on the agent array.%0A     */%0A    public ClearableRandomSequence(final Steppable%5B%5D agents,%0A                                   final boolean shouldSynchronize) %7B%0A        super(agents, shouldSynchronize);%0A        this.setUsesSets(true);%0A    %7D%0A%0A    /**%0A     * Constructor.%0A     *%0A     * @param collection%0A     *        The initial collection of agents to use.%0A     * @param shouldSynchronize%0A     *        Whether or not to synchronize on the agent collection.%0A     */%0A    public ClearableRandomSequence(final Collection%3CSteppable%3E collection,%0A                                   final boolean shouldSynchronize) %7B%0A        super(collection, shouldSynchronize);%0A        this.setUsesSets(true);%0A    %7D%0A%0A    /**%0A     * Queues all agents in this random sequence for removal and forces the%0A     * underlying %7B@code Steppable%7D collection to do so.%0A     */%0A    public void clear() %7B%0A        // Check to ensure there are agents to remove.%0A        if(this.size != 0) %7B%0A            // Add the current list of Steppables to the removal queue.%0A            for(int i = 0; i %3C this.size; i++) %7B%0A                this.removeSteppable(this.steps%5Bi%5D);%0A            %7D%0A%0A            // Force the underlying collection to remove all agents immediately.%0A            this.loadSteps();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Returns the number of %7B@code Steppable%7D objects currently in this%0A     * sequence.%0A     *%0A     * @return The active %7B@code Steppable%7D count.%0A     */%0A    public int getSize() %7B%0A        return this.size;%0A    %7D%0A%7D%0A

Add reusable RandomSequence implementation.