@Test public void getItemAt() { assertThat(mTileList.addOrReplace(createTile(0, 1, 2, 3)), nullValue()); assertThat(mTileList.getItemAt(0), is(1)); assertThat(mTileList.getItemAt(1), is(2)); assertThat(mTileList.getItemAt(2), is(3)); assertThat(mTileList.getItemAt(3), nullValue()); }
public T getItemAt(int pos) { if (mLastAccessedTile == null || !mLastAccessedTile.containsPosition(pos)) { final int startPosition = pos - (pos % mTileSize); final int index = mTiles.indexOfKey(startPosition); if (index < 0) { return null; } mLastAccessedTile = mTiles.valueAt(index); } return mLastAccessedTile.getByPosition(pos); }
TileList { public T getItemAt(int pos) { if (mLastAccessedTile == null || !mLastAccessedTile.containsPosition(pos)) { final int startPosition = pos - (pos % mTileSize); final int index = mTiles.indexOfKey(startPosition); if (index < 0) { return null; } mLastAccessedTile = mTiles.valueAt(index); } return mLastAccessedTile.getByPosition(pos); } }
TileList { public T getItemAt(int pos) { if (mLastAccessedTile == null || !mLastAccessedTile.containsPosition(pos)) { final int startPosition = pos - (pos % mTileSize); final int index = mTiles.indexOfKey(startPosition); if (index < 0) { return null; } mLastAccessedTile = mTiles.valueAt(index); } return mLastAccessedTile.getByPosition(pos); } TileList(int tileSize); }
TileList { public T getItemAt(int pos) { if (mLastAccessedTile == null || !mLastAccessedTile.containsPosition(pos)) { final int startPosition = pos - (pos % mTileSize); final int index = mTiles.indexOfKey(startPosition); if (index < 0) { return null; } mLastAccessedTile = mTiles.valueAt(index); } return mLastAccessedTile.getByPosition(pos); } TileList(int tileSize); T getItemAt(int pos); int size(); void clear(); Tile<T> getAtIndex(int index); Tile<T> addOrReplace(Tile<T> newTile); Tile<T> removeAtPos(int startPosition); }
TileList { public T getItemAt(int pos) { if (mLastAccessedTile == null || !mLastAccessedTile.containsPosition(pos)) { final int startPosition = pos - (pos % mTileSize); final int index = mTiles.indexOfKey(startPosition); if (index < 0) { return null; } mLastAccessedTile = mTiles.valueAt(index); } return mLastAccessedTile.getByPosition(pos); } TileList(int tileSize); T getItemAt(int pos); int size(); void clear(); Tile<T> getAtIndex(int index); Tile<T> addOrReplace(Tile<T> newTile); Tile<T> removeAtPos(int startPosition);  }