public class xxxx extends ddffdssf{
private static final Logger logger = LoggerFactory.getLogger(GridManagerUseArrayList.class);
private List<ISceneObj>[][] sceneObjs;
private final ReentrantLock lock = new ReentrantLock();
public GridManagerUseArrayList(int width, int height) {
super(width, height);
sceneObjs = new List[gridWidth][gridHeight];
}
private List<ISceneObj> getSceneObjMapByGridPos(Point point, boolean create) {
if (point.getX() >= gridWidth || point.getY() >= gridHeight || point.getX() < 0 || point.getY() < 0) {
if (logger.isDebugEnabled())
logger.debug("error xy:" + point.getX() + " " + point.getY() + " max " + gridWidth + " " + gridHeight);
return null;
}
lock.lock();
List<ISceneObj> list = null;
try {
list = sceneObjs[point.getX()][point.getY()];
if (list == null && create) {
list = new ArrayList<ISceneObj>();
sceneObjs[point.getX()][point.getY()] = list;
}
} finally {
lock.unlock();
}
return list;
}
private static final Logger logger = LoggerFactory.getLogger(GridManagerUseArrayList.class);
private List<ISceneObj>[][] sceneObjs;
private final ReentrantLock lock = new ReentrantLock();
public GridManagerUseArrayList(int width, int height) {
super(width, height);
sceneObjs = new List[gridWidth][gridHeight];
}
private List<ISceneObj> getSceneObjMapByGridPos(Point point, boolean create) {
if (point.getX() >= gridWidth || point.getY() >= gridHeight || point.getX() < 0 || point.getY() < 0) {
if (logger.isDebugEnabled())
logger.debug("error xy:" + point.getX() + " " + point.getY() + " max " + gridWidth + " " + gridHeight);
return null;
}
lock.lock();
List<ISceneObj> list = null;
try {
list = sceneObjs[point.getX()][point.getY()];
if (list == null && create) {
list = new ArrayList<ISceneObj>();
sceneObjs[point.getX()][point.getY()] = list;
}
} finally {
lock.unlock();
}
return list;
}