<commit_before>package com.gamingmesh.jobs.container;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.gamingmesh.jobs.Jobs;

public class ExploreChunk {

//    private int x;
//    private int z;
    private Set<Integer> playerIds = new HashSet<>();
    private int dbId = -1;
    private boolean updated = false;

    public ExploreChunk() {
    }

//    public ExploreChunk(int x, int z) {
//	this.x = x;
//	this.z = z;
//    }

    public ExploreRespond addPlayer(int playerId) {
	if (isFullyExplored()) {
	    return new ExploreRespond(Jobs.getExplore().getPlayerAmount() + 1, false);
	}
	boolean newChunkForPlayer = false;
	if (!playerIds.contains(playerId)) {
	    if (playerIds.size() < Jobs.getExplore().getPlayerAmount()) {
		playerIds.add(playerId);
		updated = true;
	    }
	    newChunkForPlayer = true;
	}

	if (playerIds.size() >= Jobs.getExplore().getPlayerAmount()) {
	    if (Jobs.getGCManager().ExploreCompact)
		playerIds = null;
	}

	return new ExploreRespond(newChunkForPlayer ? getPlayers().size() : getPlayers().size() + 1, newChunkForPlayer);
    }

    public boolean isAlreadyVisited(int playerId) {
	return isFullyExplored() || playerIds.contains(playerId);
    }

    public int getCount() {
	return isFullyExplored() ? Jobs.getExplore().getPlayerAmount() : playerIds.size();
    }

//    public int getX() {
//	return x;
//    }
//
//    public int getZ() {
//	return z;
//    }

    public Set<Integer> getPlayers() {
	return playerIds == null ? new HashSet<>() : playerIds;
    }

    public String serializeNames() {
	if (playerIds == null)
	    return null;

	String s = "";
	for (Integer one : playerIds) {
	    if (!s.isEmpty())
		s += ";";
	    s += one;
	}
	return s;
    }

    public void deserializeNames(String names) {
	if (names == null || names.isEmpty()) {
	    playerIds = null;
	    return;
	}

	if (playerIds == null) {
	    playerIds = new HashSet<>();
	}

	List<String> split = Arrays.asList(names.split(";"));
	for (String one : split) {
	    try {
		int id = Integer.parseInt(one);
		PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(id);<commit_msg>ArrayList more efficient for memory usage<commit_after>package com.gamingmesh.jobs.container;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.gamingmesh.jobs.Jobs;

public class ExploreChunk {

    private ArrayList<Integer> playerIds = new ArrayList<>();
    private int dbId = -1;
    private boolean updated = false;

    public ExploreRespond addPlayer(int playerId) {
	if (isFullyExplored()) {
	    return new ExploreRespond(Jobs.getExplore().getPlayerAmount() + 1, false);
	}
	boolean newChunkForPlayer = false;
	if (!playerIds.contains(playerId)) {
	    if (playerIds.size() < Jobs.getExplore().getPlayerAmount()) {
		playerIds.add(playerId);
		updated = true;
	    }
	    newChunkForPlayer = true;
	}

	if (playerIds.size() >= Jobs.getExplore().getPlayerAmount() && Jobs.getGCManager().ExploreCompact) {
	    playerIds = null;
	}

	return new ExploreRespond(newChunkForPlayer ? getPlayers().size() : getPlayers().size() + 1, newChunkForPlayer);
    }

    public boolean isAlreadyVisited(int playerId) {
	return isFullyExplored() || playerIds.contains(playerId);
    }

    public int getCount() {
	return isFullyExplored() ? Jobs.getExplore().getPlayerAmount() : playerIds.size();
    }

    public ArrayList<Integer> getPlayers() {
	return playerIds == null ? new ArrayList<>() : playerIds;
    }

    public String serializeNames() {
	if (playerIds == null)
	    return null;

	StringBuilder s = new StringBuilder();
	for (Integer one : playerIds) {
	    if (!s.toString().isEmpty())
		s.append(";");
	    s.append(one);
	}
	return s.toString();
    }

    public void deserializeNames(String names) {
	if (names == null || names.isEmpty()) {
	    playerIds = null;
	    return;
	}

	if (playerIds == null) {
	    playerIds = new ArrayList<>();
	}

	List<String> split = Arrays.asList(names.split(";"));
	for (String one : split) {
	    try {
		int id = Integer.parseInt(one);
		PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(id);
{'fraction_non_alphanumeric': 0.14326923076923076, 'fraction_numerical': 0.0014423076923076924, 'mean_word_length': 3.4741935483870967, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '3401138', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1337, 'n_words': 311}