<commit_before>package net.kevxu.senselib;

import java.util.Random;

public class DataPool {

	private int mPoolSize;

	private float[][] mPool;
	private int mStartPos;
	private int mEndPos;
	private int mSize;

	public DataPool(int poolSize) {
		mPoolSize = poolSize;
		mPool = new float[mPoolSize][];
		mStartPos = 0;
		mEndPos = 0;
		mSize = 0;
	}

	public int size() {
		return mSize;
	}

	public int getPoolSize() {
		return mPoolSize;
	}

	public void append(float[] values) {
		if (mSize < mPoolSize) {
			mPool[mEndPos] = values;
			mEndPos = (mEndPos + 1) % mPoolSize;
			mSize++;
		} else {
			mStartPos = (mStartPos + 1) % mPoolSize;
			mPool[mEndPos] = values;
			mEndPos = (mEndPos + 1) % mPoolSize;
		}
	}

	public float[] get(int i) {
		if (i < mSize) {
			return mPool[(mStartPos + i) % mPoolSize];
		} else {
			throw new IndexOutOfBoundsException();
		}
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();

		str.append("[");
		for (int i = 0; i < mSize; i++) {
			float[] values = get(i);
			str.append("[");
			for (float value : values) {
				str.append(value);
				str.append(", ");
			}
			str.delete(str.length() - 2, str.length());
			str.append("], ");
		}
		str.delete(str.length() - 2, str.length());
		str.append("]");

		return str.toString();
	}

	public static void main(String[] args) {
		Random r = new Random();
		DataPool pool = new DataPool(7);
		for (int i = 0; i < 10; i++) {
			float[] values = new float[3];
			for (int j = 0; j < 3; j++) {
				values[j] = (float) r.nextInt(10);
			}
			pool.append(values);
			System.out.println(pool);
		}
	}

}<commit_msg>Building DataPool.<commit_after>package net.kevxu.senselib;

import java.util.Random;

public class DataPool {

	private int mPoolSize;

	private float[][] mPool;
	private int mStartPos;
	private int mEndPos;
	private int mSize;

	public DataPool(int poolSize) {
		mPoolSize = poolSize;
		mPool = new float[mPoolSize][];
		mStartPos = 0;
		mEndPos = 0;
		mSize = 0;
	}

	public int size() {
		return mSize;
	}

	public int getPoolSize() {
		return mPoolSize;
	}

	public void append(float[] values) {
		if (mSize < mPoolSize) {
			mPool[mEndPos] = values;
			mEndPos = (mEndPos + 1) % mPoolSize;
			mSize++;
		} else {
			mStartPos = (mStartPos + 1) % mPoolSize;
			mPool[mEndPos] = values;
			mEndPos = (mEndPos + 1) % mPoolSize;
		}
	}

	public float[] get(int i) {
		if (i < mSize) {
			return mPool[(mStartPos + i) % mPoolSize];
		} else {
			throw new IndexOutOfBoundsException();
		}
	}

	public float[][] getPrevious(int n) {
		if (n > mSize) {
			throw new IndexOutOfBoundsException("n is larger than DataPool size.");
		}

		float[][] pd = new float[n][];
		for (int i = 0; i < n; i++) {
			pd[i] = get(mSize - 1 - i);
		}
		return pd;
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();

		str.append("[");
		for (int i = 0; i < mSize; i++) {
			float[] values = get(i);
			str.append("[");
			for (float value : values) {
				str.append(value);
				str.append(", ");
			}
			str.delete(str.length() - 2, str.length());
			str.append("], ");
		}
		str.delete(str.length() - 2, str.length());
		str.append("]");

		return str.toString();
	}

	public static void main(String[] args) {
		Random r = new Random();
		DataPool pool = new DataPool(5);

		// Appending data
		System.out.println("Appending data:");
		for (int i = 0; i < 10; i++) {
			float[] values = new float[3];
			for (int j = 0; j < 3; j++) {
				values[j] = (float) r.nextInt(10);
			}
			pool.append(values);
			System.out.println(pool);
		}
		System.out.println();

		// Test get
		System.out.println("Testing get:");
		for (int i = 0; i < 20; i++) {
			try {
				float[] value = pool.get(i);
				StringBuilder sb = new StringBuilder();
				sb.append("[");
				for (int j = 0; j < 3; j++) {
					sb.append(value[j]).append(", ");
				}
				sb.delete(sb.length() - 2, sb.length());
				System.out.println(i + ": " + sb.toString());
			} catch (IndexOutOfBoundsException e) {
				e.printStackTrace();
			}
		}
		System.out.println();

		// Test getPrevious
		System.out.println("Testing getPrevious:");
		for (int i = 0; i < 10; i++) {
			try {
				float[][] pd = pool.getPrevious(i);
				StringBuilder sb = new StringBuilder();
				sb.append("[");
				for (int j = 0; j < 3; j++) {
					sb.append(pd[i][j]).append(", ");
				}
				sb.delete(sb.length() - 2, sb.length());
				sb.append("]");
				System.out.println("previous " + i + ": " + sb.toString());
			} catch (IndexOutOfBoundsException e) {
				e.printStackTrace();
			}
		}
		System.out.println();
	}
}
{'fraction_non_alphanumeric': 0.17716022579244464, 'fraction_numerical': 0.010855405992184108, 'mean_word_length': 2.944349315068493, 'pattern_counts': {'":': 2, '<': 18, '<?xml version=': 0, '>': 4, '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': '5199867', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1722, 'n_words': 432}