<commit_before>﻿using System.Collections.Generic;
using System.Linq;

namespace GoldenAnvil.Utility
{
	public static class EnumerableUtility
	{
		public static IEnumerable<T> Append<T>(this IEnumerable<T> items, T value)
		{
			foreach (T item in items)
				yield return item;
			yield return value;
		}

		public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> items)
		{
			return items ?? Enumerable.Empty<T>();
		}

		public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T> items)
		{
			return items.Where(x => x != null);
		}

		public static IEnumerable<T> Enumerate<T>(params T[] items)
		{
			return items;
		}
	}
}<commit_msg>Add AsReadOnlyList; Remove obsolete method<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace GoldenAnvil.Utility
{
	public static class EnumerableUtility
	{
		public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> items)
		{
			return items ?? Enumerable.Empty<T>();
		}

		public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T> items)
		{
			return items.Where(x => x != null);
		}

		public static IEnumerable<T> Enumerate<T>(params T[] items)
		{
			return items;
		}

		public static IReadOnlyList<T> AsReadOnlyList<T>(this IEnumerable<T> items)
		{
			return items as IReadOnlyList<T> ??
				(items is IList<T> list ? (IReadOnlyList<T>) new ReadOnlyListAdapter<T>(list) : items.ToList().AsReadOnly());
		}

		private sealed class ReadOnlyListAdapter<T> : IReadOnlyList<T>
		{
			public ReadOnlyListAdapter(IList<T> list) => m_list = list ?? throw new ArgumentNullException(nameof(list));

			public int Count => m_list.Count;
			public T this[int index] => m_list[index];
			public IEnumerator<T> GetEnumerator() => m_list.GetEnumerator();
			IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable) m_list).GetEnumerator();

			readonly IList<T> m_list;
		}
	}
}
{'fraction_non_alphanumeric': 0.1225130890052356, 'fraction_numerical': 0.0, 'mean_word_length': 4.670623145400594, 'pattern_counts': {'":': 0, '<': 36, '<?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': '3506170', 'n_tokens_mistral': 696, 'n_tokens_neox': 632, 'n_words': 152}