<commit_before>"use strict";

module.exports = class Queue {
	constructor(items) {
		this.first = null;
		this.last = null;
		this.recycle = [];
		this.length = 0;
		if(items) {
			for(const item of items) {
				this.enqueue(item);
			}
		}
	}

	enqueue(item) {
		const first = this.first;
		let node;
		if(this.recycle.length > 0) {
			node = this.recycle.pop();
			node.item = item;
			node.next = null;
		} else {
			node = {
				item,
				next: null
			};
		}
		if(first === null) {
			this.last = node;
		} else {
			first.next = node;
		}
		this.first = node;
		this.length++;
	}

	dequeue() {
		const last = this.last;
		if(last === null)
			return undefined;
		const next = last.next;
		if(next === null) {
			this.first = null;
		}
		this.last = next;
		this.length--;
		this.recycle.push(last);
		return last.item;
	}
};<commit_msg>ensure that items are not enqueued twice<commit_after>"use strict";

module.exports = class Queue {
	constructor(items) {
		this.set = new Set(items);
		this.iterator = this.set[Symbol.iterator]();
	}

	get length() {
		return this.set.size;
	}

	enqueue(item) {
		this.set.add(item);
	}

	dequeue() {
		const result = this.iterator.next();
		if(result.done) return undefined;
		this.set.delete(result.value);
		return result.value;
	}
};
{'fraction_non_alphanumeric': 0.16015625, 'fraction_numerical': 0.0015625, 'mean_word_length': 2.8125, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6371238', 'n_tokens_mistral': 555, 'n_tokens_neox': 483, 'n_words': 102}