<commit_before>package com.castlefrog.agl

import java.util.ArrayList

/**
 * Keeps track of state transition history.
 */
class History<S : State<S>, A : Action<A>>(initialState: S) {

    private val nodes: MutableList<Node<S, A>> = ArrayList()

    var index: Int = 0
        private set

    data class Node<S, A>(val state: S, val actions: List<A>)

    init {
        add(initialState)
    }

    fun clear() {
        val initialState = nodes[0].state
        nodes.clear()
        add(initialState)
        index = 0
    }

    private fun add(state: S) {
        add(state, ArrayList<A>())
    }

    /**
     * Add the next state and the actions taken by each agent
     * to arrive at that state.
     * @param state<commit_msg>added type param inference<commit_after>package com.castlefrog.agl

import java.util.ArrayList

/**
 * Keeps track of state transition history.
 */
class History<S : State<S>, A : Action<A>>(initialState: S) {

    private val nodes: MutableList<Node<S, A>> = ArrayList()

    var index: Int = 0
        private set

    data class Node<out S, out A>(val state: S, val actions: List<A>)

    init {
        add(initialState)
    }

    fun clear() {
        val initialState = nodes[0].state
        nodes.clear()
        add(initialState)
        index = 0
    }

    private fun add(state: S) {
        add(state, ArrayList<A>())
    }

    /**
     * Add the next state and the actions taken by each agent
     * to arrive at that state.
     * @param state
{'fraction_non_alphanumeric': 0.11474316210807205, 'fraction_numerical': 0.004002668445630421, 'mean_word_length': 2.303964757709251, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '3511869', 'n_tokens_mistral': 475, 'n_tokens_neox': 455, 'n_words': 148}