<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using EncompassRest.Utilities;
using Newtonsoft.Json;

namespace EncompassRest
{
    /// <summary>
    /// Collection to use for dirty checking.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    [JsonConverter(typeof(DirtyListConverter<>))]
    internal sealed class DirtyList<T> : IList<T>, IDirty
    {
        internal readonly List<DirtyValue<T>> _list;

        public T this[int index]
        {
            get
            {
                return _list[index];
            }
            set
            {
                _list[index] = value;
            }
        }

        public bool Dirty
        {
            get
            {
                return _list.Any(item => item.Dirty);
            }
            set
            {
                for (var i = 0; i < _list.Count; ++i)
                {
                    var item = _list[i];
                    item.Dirty = value;
                    _list[i] = item;
                }
            }
        }

        public int Count => _list.Count;

        public bool IsReadOnly => false;

        public DirtyList()
        {
            _list = new List<DirtyValue<T>>();
        }

        public DirtyList(IEnumerable<T> list)
            : this()
        {
            foreach (var item in list)
            {
                Add(item);
            }
        }

        public void Add(T item) => _list.Add(item);

        public void Clear() => _list.Clear();

        public bool Contains(T item) => IndexOf(item) >= 0;

        public void CopyTo(T[] array, int arrayIndex)
        {
            Preconditions.NotNull(array, nameof(array));
            Preconditions.LessThan(arrayIndex, nameof(arrayIndex), array.Length);
            Preconditions.GreaterThanOrEquals(array.Length - arrayIndex, $"{nameof(array)}.Length - {nameof(arrayIndex)}", Count, nameof(Count));
            
            for (var i = 0; i < _list.Count; ++i)
            {
                array[arrayIndex + i] = _list[i];
            }
        }

        public IEnumerator<T> GetEnumerator()
        {
            foreach (var item in _list)
            {<commit_msg>Small update to include named parameter in bounds checked throwed exception<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using EncompassRest.Utilities;
using Newtonsoft.Json;

namespace EncompassRest
{
    /// <summary>
    /// Collection to use for dirty checking.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    [JsonConverter(typeof(DirtyListConverter<>))]
    internal sealed class DirtyList<T> : IList<T>, IDirty
    {
        internal readonly List<DirtyValue<T>> _list;

        public T this[int index]
        {
            get
            {
                return _list[index];
            }
            set
            {
                _list[index] = value;
            }
        }

        public bool Dirty
        {
            get
            {
                return _list.Any(item => item.Dirty);
            }
            set
            {
                for (var i = 0; i < _list.Count; ++i)
                {
                    var item = _list[i];
                    item.Dirty = value;
                    _list[i] = item;
                }
            }
        }

        public int Count => _list.Count;

        public bool IsReadOnly => false;

        public DirtyList()
        {
            _list = new List<DirtyValue<T>>();
        }

        public DirtyList(IEnumerable<T> list)
            : this()
        {
            foreach (var item in list)
            {
                Add(item);
            }
        }

        public void Add(T item) => _list.Add(item);

        public void Clear() => _list.Clear();

        public bool Contains(T item) => IndexOf(item) >= 0;

        public void CopyTo(T[] array, int arrayIndex)
        {
            Preconditions.NotNull(array, nameof(array));
            Preconditions.LessThan(arrayIndex, nameof(arrayIndex), array.Length, $"{nameof(array)}.Length");
            Preconditions.GreaterThanOrEquals(array.Length - arrayIndex, $"{nameof(array)}.Length - {nameof(arrayIndex)}", Count, nameof(Count));
            
            for (var i = 0; i < _list.Count; ++i)
            {
                array[arrayIndex + i] = _list[i];
            }
        }

        public IEnumerator<T> GetEnumerator()
        {
            foreach (var item in _list)
            {
{'fraction_non_alphanumeric': 0.10965200262639527, 'fraction_numerical': 0.0013131976362442547, 'mean_word_length': 1.3764950598023922, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 43, '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': '4987042', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1242, 'n_words': 291}