<commit_before>package io.particle.android.sdk.ui

import androidx.collection.SparseArrayCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import io.particle.android.sdk.cloud.ParticleDevice
import io.particle.android.sdk.tinker.TinkerFragment
import io.particle.android.sdk.ui.FunctionsAndVariablesFragment.DisplayMode


private data class FragmentData(val title: String, val fragment: Fragment)


internal class InspectorPager(
    fm: FragmentManager,
    device: ParticleDevice
) : FragmentStatePagerAdapter(fm) {

    // NOTE: the keys in this map are the positions of the fragments.
    private val fragmentsData = SparseArrayCompat<FragmentData>().apply {
        addAllInThisOrder(
            "Events" to EventsFragment.newInstance(device),
            "Functions" to FunctionsAndVariablesFragment.newInstance(device, DisplayMode.FUNCTIONS),
            "Variables" to FunctionsAndVariablesFragment.newInstance(device, DisplayMode.VARIABLES),
            "Tinker" to TinkerFragment.newInstance(device)
        )
    }

    private val isRunningTinker = device.isRunningTinker

    override fun getPageTitle(position: Int): CharSequence? {
        return fragmentsData[position]?.title
    }

    override fun getItem(position: Int): Fragment {
        return fragmentsData[position]?.fragment!!
    }

    override fun getCount(): Int {
        return if (isRunningTinker) 4 else 3
    }
}


private fun SparseArrayCompat<FragmentData>.addAllInThisOrder(vararg pairs: Pair<String, Fragment>) {
    pairs.forEachIndexed { index, element ->
        this.put(index, FragmentData(element.first, element.second))
    }
}<commit_msg>Better naming<commit_after>package io.particle.android.sdk.ui

import androidx.collection.SparseArrayCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import io.particle.android.sdk.cloud.ParticleDevice
import io.particle.android.sdk.tinker.TinkerFragment
import io.particle.android.sdk.ui.FunctionsAndVariablesFragment.DisplayMode


private data class FragmentData(val title: String, val fragment: Fragment)


internal class InspectorPager(
    fm: FragmentManager,
    device: ParticleDevice
) : FragmentStatePagerAdapter(fm) {

    // NOTE: the keys in this map are the positions of the fragments.
    private val fragmentsData = SparseArrayCompat<FragmentData>().apply {
        addInGivenOrder(
            "Events" to EventsFragment.newInstance(device),
            "Functions" to FunctionsAndVariablesFragment.newInstance(device, DisplayMode.FUNCTIONS),
            "Variables" to FunctionsAndVariablesFragment.newInstance(device, DisplayMode.VARIABLES),
            "Tinker" to TinkerFragment.newInstance(device)
        )
    }

    private val isRunningTinker = device.isRunningTinker

    override fun getPageTitle(position: Int): CharSequence? {
        return fragmentsData[position]?.title
    }

    override fun getItem(position: Int): Fragment {
        return fragmentsData[position]?.fragment!!
    }

    override fun getCount(): Int {
        return if (isRunningTinker) 4 else 3
    }
}


private fun SparseArrayCompat<FragmentData>.addInGivenOrder(vararg pairs: Pair<String, Fragment>) {
    pairs.forEachIndexed { index, element ->
        this.put(index, FragmentData(element.first, element.second))
    }
}
{'fraction_non_alphanumeric': 0.08559861191440139, 'fraction_numerical': 0.001156737998843262, 'mean_word_length': 4.101769911504425, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5147114', 'n_tokens_mistral': 980, 'n_tokens_neox': 910, 'n_words': 209}