<commit_before>package com.artemis.managers;

import java.util.HashMap;
import java.util.Map;

import com.artemis.Entity;
import com.artemis.Manager;
import com.artemis.World;


/**
 * If you need to tag any entity, use this. A typical usage would be to tag
 * entities such as "PLAYER". After creating an entity call register().
 * 
 * @author <NAME>
 *
 */
public class TagManager extends Manager {
	private World world;
	private Map<String, Entity> entityByTag;

	public TagManager(World world) {
		this.world = world;
		entityByTag = new HashMap<String, Entity>();
	}

	public void register(String tag, Entity e) {
		entityByTag.put(tag, e);
	}

	public void unregister(String tag) {
		entityByTag.remove(tag);
	}

	public boolean isRegistered(String tag) {
		return entityByTag.containsKey(tag);
	}

	public Entity getEntity(String tag) {
		return entityByTag.get(tag);
	}
	
	protected void remove(Entity e) {
		entityByTag.values().remove(e);
	}

	@Override
	protected void changed(Entity e) {
	}

	@Override
	protected void added(Entity e) {
	}

	@Override
	protected void deleted(Entity e) {
	}

	@Override
	protected void initialize() {
	}

}
<commit_msg>Refactoring TagManager.<commit_after>package com.artemis.managers;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.artemis.Entity;
import com.artemis.Manager;


/**
 * If you need to tag any entity, use this. A typical usage would be to tag
 * entities such as "PLAYER", "BOSS" or something that is very unique.
 * 
 * @author <NAME>
 *
 */
public class TagManager extends Manager {
	private Map<String, Entity> entitiesByTag;
	private Map<Entity, String> tagsByEntity;

	public TagManager() {
		entitiesByTag = new HashMap<>();
		tagsByEntity = new HashMap<>();
	}

	public void register(String tag, Entity e) {
		entitiesByTag.put(tag, e);
		tagsByEntity.put(e, tag);
	}

	public void unregister(String tag) {
		tagsByEntity.remove(entitiesByTag.remove(tag));
	}

	public boolean isRegistered(String tag) {
		return entitiesByTag.containsKey(tag);
	}

	public Entity getEntity(String tag) {
		return entitiesByTag.get(tag);
	}
	
	public Collection<String> getRegisteredTags() {
		return tagsByEntity.values();
	}
	
	@Override
	protected void changed(Entity e) {
	}

	@Override
	protected void added(Entity e) {
	}

	@Override
	protected void deleted(Entity e) {
		String removedTag = tagsByEntity.remove(e);
		if(removedTag != null) {
			entitiesByTag.remove(removedTag);
		}
	}

	@Override
	protected void initialize() {
	}

}

{'fraction_non_alphanumeric': 0.10648668916385452, 'fraction_numerical': 0.0, 'mean_word_length': 3.331168831168831, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '2480446', 'n_tokens_mistral': 911, 'n_tokens_neox': 832, 'n_words': 230}