<commit_before>package com.unidev.lib.matrix.utils;

import com.unidev.lib.matrix.model.Coordinate;
import com.unidev.lib.matrix.model.Matrix;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * Utils code to work with matrix instances
 */
public class MatrixUtils {

    public static <T> void shuffle(Matrix<T> matrix) {
        List<T> elements = new ArrayList<T>();
        Iterator<T> iterator = matrix.iterator();
        while(iterator.hasNext()) {
            elements.add(iterator.next());
        }
        Collections.shuffle(elements);

        for(Integer row = 0;row < matrix.getRows();row++) {
            for(Integer col = 0;col < matrix.getColumns();col++) {
                T element = elements.get(0);
                elements.remove((int)0);
                matrix.set(Coordinate.coordinate().withRow(row).withColumn(col), element);
            }
        }

    }
<commit_msg>usage of collection index<commit_after>package com.unidev.lib.matrix.utils;

import com.unidev.lib.matrix.model.Coordinate;
import com.unidev.lib.matrix.model.Matrix;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * Utils code to work with matrix instances
 */
public class MatrixUtils {

    public static <T> void shuffle(Matrix<T> matrix) {
        List<T> elements = new ArrayList<T>();
        Iterator<T> iterator = matrix.iterator();
        while(iterator.hasNext()) {
            elements.add(iterator.next());
        }
        Collections.shuffle(elements);

        int collectonIndex = 0;
        for(Integer row = 0;row < matrix.getRows();row++) {
            for(Integer col = 0;col < matrix.getColumns();col++) {
                T element = elements.get(collectonIndex++);
                matrix.set(Coordinate.coordinate().withRow(row).withColumn(col), element);
            }
        }

    }

{'fraction_non_alphanumeric': 0.13402061855670103, 'fraction_numerical': 0.0036082474226804126, 'mean_word_length': 2.6622641509433964, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '2403328', 'n_tokens_mistral': 578, 'n_tokens_neox': 555, 'n_words': 113}