<commit_before>package net.sandius.rembulan.util;

import java.util.Arrays;

public class IntSet extends IntContainer {

	private final int[] values;

	private IntSet(int[] values) {
		// values must be sorted
		this.values = Check.notNull(values);
	}

//	public static IntSet from(int[] values) {
//		Check.notNull(values);
//		int[] sorted = Arrays.copyOf(values, values.length);
//		Arrays.sort(sorted);
//
//		// remove duplicates
//
//		return new IntSet(copy);
//	}

	public static IntSet empty() {
		return new IntSet(new int[0]);
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		IntSet intSet = (IntSet) o;
		return Arrays.equals(values, intSet.values);<commit_msg>Adding more static constructor methods for int sets.<commit_after>package net.sandius.rembulan.util;

import java.util.Arrays;

public class IntSet extends IntContainer {

	private final int[] values;

	private IntSet(int[] values) {
		// values must be sorted
		this.values = Check.notNull(values);
	}

	public static IntSet empty() {
		return new IntSet(new int[0]);
	}

	public static IntSet singleton(int i) {
		return new IntSet(new int[] { i });
	}

	public static IntSet from(int[] values) {
		Check.notNull(values);

		if (values.length == 0) {
			return empty();
		}
		else if (values.length == 1) {
			return singleton(values[0]);
		}
		else {
			// sort
			int[] sorted = Arrays.copyOf(values, values.length);
			Arrays.sort(sorted);

			// skip duplicates in place
			int uniq = 1;
			for (int i = 1; i < sorted.length; i++) {
				if (sorted[i] != sorted[i - 1]) {
					sorted[uniq] = sorted[i];
					uniq++;
				}
			}

			return new IntSet(Arrays.copyOf(sorted, uniq));
		}
	}

	public static IntSet from(IntContainer container) {
		return empty().plus(container);
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		IntSet intSet = (IntSet) o;
		return Arrays.equals(values, intSet.values);
{'fraction_non_alphanumeric': 0.14493456131846824, 'fraction_numerical': 0.003877847794474067, 'mean_word_length': 3.4387096774193546, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '2892248', 'n_tokens_mistral': 781, 'n_tokens_neox': 704, 'n_words': 196}