<commit_before>package org.openlca.git.util;

import java.util.Collection;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Set;
import java.util.function.BiConsumer;

import org.openlca.core.model.ModelType;
import org.openlca.git.model.Reference;

public class TypeRefIdSet {

	private final EnumMap<ModelType, Set<String>> map = new EnumMap<>(ModelType.class);

	public TypeRefIdSet() {
	}
	
	public TypeRefIdSet(Collection<Reference> refs) {
		refs.forEach(r -> add(r.type, r.refId));
	}
	
	public void add(ModelType type, String refId) {
		map.computeIfAbsent(type, t -> new HashSet<>()).add(refId);
	}

	public boolean contains(ModelType type, String refId) {
		var refIds = map.get(type);
		if (refIds == null)
			return false;
		return refIds.contains(refId);
	}
	
	public void remove(ModelType type, String refId) {
		var refIds = map.get(type);
		if (refIds == null)
			return;
		refIds.remove(refId);		
	}

	public void clear() {
		map.clear();
	}

	public void forEach(BiConsumer<ModelType, String> forEach) {
		map.keySet().forEach(type -> {
			var refIds = map.get(type);
			if (refIds == null)
				return;
			refIds.forEach(refId -> forEach.accept(type, refId));
		});
	}

	public Set<String> get(ModelType type) {
		var refIds = map.get(type);
		if (refIds == null)
			return new HashSet<>();
		return refIds;
	}

	public Set<String> refIds() {
		var refIds = new HashSet<String>();
		map.values().forEach(set -> refIds.addAll(set));
		return refIds;
	}
	
	public ModelType getTypeFor(String refId) {
		for (var type : map.keySet())
			if (map.get(type) != null && map.get(type).contains(refId))
				return type;
		return null;
	}

	public interface ForEach {

		void apply(ModelType type, String refId);

	}

}<commit_msg>Added method to retrieve keys<commit_after>package org.openlca.git.util;

import java.util.Collection;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Set;
import java.util.function.BiConsumer;

import org.openlca.core.model.ModelType;
import org.openlca.git.model.Reference;

public class TypeRefIdSet {

	private final EnumMap<ModelType, Set<String>> map = new EnumMap<>(ModelType.class);

	public TypeRefIdSet() {
	}
	
	public TypeRefIdSet(Collection<Reference> refs) {
		refs.forEach(r -> add(r.type, r.refId));
	}
	
	public void add(ModelType type, String refId) {
		map.computeIfAbsent(type, t -> new HashSet<>()).add(refId);
	}

	public boolean contains(ModelType type, String refId) {
		var refIds = map.get(type);
		if (refIds == null)
			return false;
		return refIds.contains(refId);
	}
	
	public void remove(ModelType type, String refId) {
		var refIds = map.get(type);
		if (refIds == null)
			return;
		refIds.remove(refId);		
	}

	public void clear() {
		map.clear();
	}

	public void forEach(BiConsumer<ModelType, String> forEach) {
		map.keySet().forEach(type -> {
			var refIds = map.get(type);
			if (refIds == null)
				return;
			refIds.forEach(refId -> forEach.accept(type, refId));
		});
	}

	public Set<String> get(ModelType type) {
		var refIds = map.get(type);
		if (refIds == null)
			return new HashSet<>();
		return refIds;
	}

	public Set<String> refIds() {
		var refIds = new HashSet<String>();
		map.values().forEach(set -> refIds.addAll(set));
		return refIds;
	}
	
	public Set<ModelType> types() {
		return new HashSet<>(map.keySet());
	}
	
	public ModelType getTypeFor(String refId) {
		for (var type : map.keySet())
			if (map.get(type) != null && map.get(type).contains(refId))
				return type;
		return null;
	}

	public interface ForEach {

		void apply(ModelType type, String refId);

	}

}
{'fraction_non_alphanumeric': 0.14238227146814406, 'fraction_numerical': 0.0, 'mean_word_length': 3.9601648351648353, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 35, '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': '3018254', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1266, 'n_words': 298}