<commit_before>package org.andengine.opengl.texture.region;

import org.andengine.opengl.texture.ITexture;
import org.andengine.opengl.texture.Texture;

/**
 * (c) 2010 <NAME>
 * (c) 2011 Zynga Inc.
 * 
 * @author <NAME>
 * @since 18:14:42 - 09.03.2010
 */
public class TiledTextureRegion extends BaseTextureRegion implements ITiledTextureRegion {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	protected int mTileIndex;
	protected final int mTileCount;
	protected final ITextureRegion[] mTextureRegions;

	// ===========================================================
	// Constructors
	// ===========================================================

	public TiledTextureRegion(final ITexture pTexture, final ITextureRegion ... pTextureRegions) {
		this(pTexture, true, pTextureRegions);
	}

	/**
	 * @param pTexture
	 * @param pPerformSameTextureSanityCheck checks whether all supplied {@link ITextureRegion} are on the same {@link Texture}
	 * @param pTextureRegions
	 */
	public TiledTextureRegion(final ITexture pTexture, final boolean pPerformSameTextureSanityCheck, final ITextureRegion ... pTextureRegions) {
		super(pTexture);
		
		this.mTextureRegions = pTextureRegions;
		this.mTileCount = this.mTextureRegions.length;

		if(pPerformSameTextureSanityCheck) {
			for(int i = this.mTileCount - 1; i >= 0; i--) {
				if(pTextureRegions[i].getTexture() != pTexture) {
					throw new IllegalArgumentException("The " + ITextureRegion.class.getSimpleName() + ": '" + pTextureRegions[i].toString() + "' at index: '" + i + "' is not on the same " + ITexture.class.getSimpleName() + ": '" + pTextureRegions[i].getTexture().toString() + "' as the supplied " + ITexture.class.getSimpleName() + ": '" + pTexture.toString() + "'.");
				}
			}
		}
	}

	public static TiledTextureRegion create(final ITexture pTexture, final int pX, final int pY, final int pWidth, final int pHeight, final int pTileColumns, final int pTileRows) {
		return TiledTextureRegion.create(pTexture, pX, pY, pWidth, pHeight, pTileColumns, pTileRows, false);
	}

	public static TiledTextureRegion create(final ITexture pTexture, final int pX, final int pY, final int pWidth, final int pHeight, final int pTileColumns, final int pTileRows, final boolean pRotated) {
		final ITextureRegion[] textureRegions = new ITextureRegion[pTileColumns * pTileRows];

		final int tileWidth = pWidth / pTileColumns;
		final int tileHeight = pHeight / pTileRows;

		for(int tileColumn = 0; tileColumn < pTileColumns; tileColumn++) {
			for(int tileRow = 0; tileRow < pTileRows; tileRow++) {
				final int tileIndex = tileRow * pTileColumns + tileColumn;

				final int x = pX + tileColumn * tileWidth;
				final int y = pY + tileRow * tileHeight;
				textureRegions[tileIndex] = new TextureRegion(pTexture, x, y, tileWidth, tileHeight, pRotated);
			}
		}

		return new TiledTextureRegion(pTexture, false, textureRegions);
	}

	@Override
	public TiledTextureRegion deepCopy() {
		final int tileCount = this.mTileCount;

		final ITextureRegion[] textureRegions = new ITextureRegion[tileCount];

		for(int i = 0; i < tileCount; i++) {
			if(this.mTextureRegions[i].getTexture() != this.mTexture) {
				throw new IllegalArgumentException("Illegal TextureRegion detected that does not match the Texture passed.");
			}

			textureRegions[i] = this.mTextureRegions[i].deepCopy();
		}

		return new TiledTextureRegion(this.mTexture, false, textureRegions);
	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	@Override
	public int getTileIndex() {
		return this.mTileIndex;
	}

	@Override
	public void setTileIndex(final int pTileIndex) {
		this.mTileIndex = pTileIndex;
	}

	@Override
	public void nextTile() {
		this.mTileIndex++;<commit_msg>TiledTextureRegion.deepCopy() doesn't perform Texture check anymore.<commit_after>package org.andengine.opengl.texture.region;

import org.andengine.opengl.texture.ITexture;
import org.andengine.opengl.texture.Texture;

/**
 * (c) 2010 <NAME>
 * (c) 2011 Zynga Inc.
 * 
 * @author <NAME>
 * @since 18:14:42 - 09.03.2010
 */
public class TiledTextureRegion extends BaseTextureRegion implements ITiledTextureRegion {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	protected int mTileIndex;
	protected final int mTileCount;
	protected final ITextureRegion[] mTextureRegions;

	// ===========================================================
	// Constructors
	// ===========================================================

	public TiledTextureRegion(final ITexture pTexture, final ITextureRegion ... pTextureRegions) {
		this(pTexture, true, pTextureRegions);
	}

	/**
	 * @param pTexture
	 * @param pPerformSameTextureSanityCheck checks whether all supplied {@link ITextureRegion} are on the same {@link Texture}
	 * @param pTextureRegions
	 */
	public TiledTextureRegion(final ITexture pTexture, final boolean pPerformSameTextureSanityCheck, final ITextureRegion ... pTextureRegions) {
		super(pTexture);
		
		this.mTextureRegions = pTextureRegions;
		this.mTileCount = this.mTextureRegions.length;

		if(pPerformSameTextureSanityCheck) {
			for(int i = this.mTileCount - 1; i >= 0; i--) {
				if(pTextureRegions[i].getTexture() != pTexture) {
					throw new IllegalArgumentException("The " + ITextureRegion.class.getSimpleName() + ": '" + pTextureRegions[i].toString() + "' at index: '" + i + "' is not on the same " + ITexture.class.getSimpleName() + ": '" + pTextureRegions[i].getTexture().toString() + "' as the supplied " + ITexture.class.getSimpleName() + ": '" + pTexture.toString() + "'.");
				}
			}
		}
	}

	public static TiledTextureRegion create(final ITexture pTexture, final int pX, final int pY, final int pWidth, final int pHeight, final int pTileColumns, final int pTileRows) {
		return TiledTextureRegion.create(pTexture, pX, pY, pWidth, pHeight, pTileColumns, pTileRows, false);
	}

	public static TiledTextureRegion create(final ITexture pTexture, final int pX, final int pY, final int pWidth, final int pHeight, final int pTileColumns, final int pTileRows, final boolean pRotated) {
		final ITextureRegion[] textureRegions = new ITextureRegion[pTileColumns * pTileRows];

		final int tileWidth = pWidth / pTileColumns;
		final int tileHeight = pHeight / pTileRows;

		for(int tileColumn = 0; tileColumn < pTileColumns; tileColumn++) {
			for(int tileRow = 0; tileRow < pTileRows; tileRow++) {
				final int tileIndex = tileRow * pTileColumns + tileColumn;

				final int x = pX + tileColumn * tileWidth;
				final int y = pY + tileRow * tileHeight;
				textureRegions[tileIndex] = new TextureRegion(pTexture, x, y, tileWidth, tileHeight, pRotated);
			}
		}

		return new TiledTextureRegion(pTexture, false, textureRegions);
	}

	@Override
	public TiledTextureRegion deepCopy() {
		final int tileCount = this.mTileCount;

		final ITextureRegion[] textureRegions = new ITextureRegion[tileCount];

		for(int i = 0; i < tileCount; i++) {
			textureRegions[i] = this.mTextureRegions[i].deepCopy();
		}

		return new TiledTextureRegion(this.mTexture, false, textureRegions);
	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	@Override
	public int getTileIndex() {
		return this.mTileIndex;
	}

	@Override
	public void setTileIndex(final int pTileIndex) {
		this.mTileIndex = pTileIndex;
	}

	@Override
	public void nextTile() {
		this.mTileIndex++;
{'fraction_non_alphanumeric': 0.21849798387096775, 'fraction_numerical': 0.006804435483870968, 'mean_word_length': 4.994712990936556, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5999666', 'n_tokens_mistral': 2510, 'n_tokens_neox': 2244, 'n_words': 574}