1cfd74d65d832137e20e193c960802afba73b5d38sm/* 23c1e67e433728684b5f228c5d4f3e5b1457bb271sm * Copyright (C) 2010 The Android Open Source Project 3cfd74d65d832137e20e193c960802afba73b5d38sm * 4cfd74d65d832137e20e193c960802afba73b5d38sm * Licensed under the Apache License, Version 2.0 (the "License"); 5cfd74d65d832137e20e193c960802afba73b5d38sm * you may not use this file except in compliance with the License. 6cfd74d65d832137e20e193c960802afba73b5d38sm * You may obtain a copy of the License at 7cfd74d65d832137e20e193c960802afba73b5d38sm * 8cfd74d65d832137e20e193c960802afba73b5d38sm * http://www.apache.org/licenses/LICENSE-2.0 9cfd74d65d832137e20e193c960802afba73b5d38sm * 10cfd74d65d832137e20e193c960802afba73b5d38sm * Unless required by applicable law or agreed to in writing, software 11cfd74d65d832137e20e193c960802afba73b5d38sm * distributed under the License is distributed on an "AS IS" BASIS, 12cfd74d65d832137e20e193c960802afba73b5d38sm * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cfd74d65d832137e20e193c960802afba73b5d38sm * See the License for the specific language governing permissions and 14cfd74d65d832137e20e193c960802afba73b5d38sm * limitations under the License. 15cfd74d65d832137e20e193c960802afba73b5d38sm */ 16cfd74d65d832137e20e193c960802afba73b5d38sm 17cfd74d65d832137e20e193c960802afba73b5d38smpackage com.replica.replicaisland; 18cfd74d65d832137e20e193c960802afba73b5d38sm 19cfd74d65d832137e20e193c960802afba73b5d38sm/** 20cfd74d65d832137e20e193c960802afba73b5d38sm * A pool of 2D vectors. 21cfd74d65d832137e20e193c960802afba73b5d38sm */ 22cfd74d65d832137e20e193c960802afba73b5d38smpublic class VectorPool extends TObjectPool<Vector2> { 23cfd74d65d832137e20e193c960802afba73b5d38sm 24cfd74d65d832137e20e193c960802afba73b5d38sm public VectorPool() { 25cfd74d65d832137e20e193c960802afba73b5d38sm super(); 26cfd74d65d832137e20e193c960802afba73b5d38sm } 27cfd74d65d832137e20e193c960802afba73b5d38sm 28cfd74d65d832137e20e193c960802afba73b5d38sm @Override 29cfd74d65d832137e20e193c960802afba73b5d38sm protected void fill() { 30cfd74d65d832137e20e193c960802afba73b5d38sm for (int x = 0; x < getSize(); x++) { 31cfd74d65d832137e20e193c960802afba73b5d38sm getAvailable().add(new Vector2()); 32cfd74d65d832137e20e193c960802afba73b5d38sm } 33cfd74d65d832137e20e193c960802afba73b5d38sm } 34cfd74d65d832137e20e193c960802afba73b5d38sm 35cfd74d65d832137e20e193c960802afba73b5d38sm @Override 36cfd74d65d832137e20e193c960802afba73b5d38sm public void release(Object entry) { 37cfd74d65d832137e20e193c960802afba73b5d38sm ((Vector2)entry).zero(); 38cfd74d65d832137e20e193c960802afba73b5d38sm super.release(entry); 39cfd74d65d832137e20e193c960802afba73b5d38sm } 40cfd74d65d832137e20e193c960802afba73b5d38sm 41cfd74d65d832137e20e193c960802afba73b5d38sm /** Allocates a vector and assigns the value of the passed source vector to it. */ 42cfd74d65d832137e20e193c960802afba73b5d38sm public Vector2 allocate(Vector2 source) { 43cfd74d65d832137e20e193c960802afba73b5d38sm Vector2 entry = super.allocate(); 44cfd74d65d832137e20e193c960802afba73b5d38sm entry.set(source); 45cfd74d65d832137e20e193c960802afba73b5d38sm return entry; 46cfd74d65d832137e20e193c960802afba73b5d38sm } 47cfd74d65d832137e20e193c960802afba73b5d38sm 48cfd74d65d832137e20e193c960802afba73b5d38sm} 49