<commit_before>﻿#region

using System;
using System.Collections;
using System.Collections.Generic;

#endregion

namespace Tabster.Core.Data
{
    public class TabsterDocumentCollection<T> : ICollection<T> where T : class, ITabsterDocument
    {
        private readonly List<T> _documents = new List<T>();

        #region Implementation of IEnumerable

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public IEnumerator<T> GetEnumerator()
        {
            foreach (var doc in _documents)
            {
                yield return doc;
            }
        }

        #endregion

        #region Implementation of ICollection<ITabsterDocument>

        public int Count
        {
            get { return _documents.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public void Add(T item)
        {
            Remove(item);
            _documents.Add(item);
        }

        public void Clear()
        {
            _documents.Clear();
        }

        public bool Contains(T item)
        {
            return _documents.Contains(item);
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            _documents.CopyTo(array, arrayIndex);
        }

        public bool Remove(T item)
        {
            return _documents.Remove(item);
        }

        #endregion

        public bool Contains(string path)
        {
            return Find(x => x.FileInfo.FullName.Equals(path, StringComparison.OrdinalIgnoreCase)) != null;
        }

        public T Find(Predicate<T> match)
        {
            return _documents.Find(match);
        }

        public List<T> FindAll(Predicate<T> match)
        {
            return _documents.FindAll(match);
        }

        public T Find(string path)
        {
            return Find(x => x.FileInfo.FullName.Equals(path, StringComparison.OrdinalIgnoreCase));
        }

        public bool Remove(string path)
        {
            var existing = _documents.Find(t => t.FileInfo.FullName.Equals(path, StringComparison.OrdinalIgnoreCase));
            return existing != null && _documents.Remove(existing);
        }
    }
}<commit_msg>LINQ.<commit_after>﻿#region

using System;
using System.Collections;
using System.Collections.Generic;

#endregion

namespace Tabster.Core.Data
{
    public class TabsterDocumentCollection<T> : ICollection<T> where T : class, ITabsterDocument
    {
        private readonly List<T> _documents = new List<T>();

        #region Implementation of IEnumerable

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public IEnumerator<T> GetEnumerator()
        {
            return ((IEnumerable<T>) _documents).GetEnumerator();
        }

        #endregion

        #region Implementation of ICollection<ITabsterDocument>

        public int Count
        {
            get { return _documents.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public void Add(T item)
        {
            Remove(item);
            _documents.Add(item);
        }

        public void Clear()
        {
            _documents.Clear();
        }

        public bool Contains(T item)
        {
            return _documents.Contains(item);
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            _documents.CopyTo(array, arrayIndex);
        }

        public bool Remove(T item)
        {
            return _documents.Remove(item);
        }

        #endregion

        public bool Contains(string path)
        {
            return Find(x => x.FileInfo.FullName.Equals(path, StringComparison.OrdinalIgnoreCase)) != null;
        }

        public T Find(Predicate<T> match)
        {
            return _documents.Find(match);
        }

        public List<T> FindAll(Predicate<T> match)
        {
            return _documents.FindAll(match);
        }

        public T Find(string path)
        {
            return Find(x => x.FileInfo.FullName.Equals(path, StringComparison.OrdinalIgnoreCase));
        }

        public bool Remove(string path)
        {
            var existing = _documents.Find(t => t.FileInfo.FullName.Equals(path, StringComparison.OrdinalIgnoreCase));
            return existing != null && _documents.Remove(existing);
        }
    }
}
{'fraction_non_alphanumeric': 0.08643302515588046, 'fraction_numerical': 0.0, 'mean_word_length': 1.521409214092141, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 28, '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': '6951701', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1179, 'n_words': 261}