Skip to content

Commit

Permalink
230412
Browse files Browse the repository at this point in the history
  • Loading branch information
Tynab committed Apr 12, 2023
1 parent 1662894 commit 99238a2
Show file tree
Hide file tree
Showing 13 changed files with 5,577 additions and 878 deletions.
9 changes: 9 additions & 0 deletions lib/YANLib/YANBool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ namespace YANLib;
public static partial class YANBool
{
public static bool GenerateRandomBool() => GenerateRandomByte(0, 2) == 1;

public static IEnumerable<bool> GenerateRandomBools<T>(T size) where T : struct
{
var cnt = size.ToUlong();
for (var i = 0ul; i < cnt; i++)
{
yield return GenerateRandomBool();
}
}
}
1,339 changes: 1,339 additions & 0 deletions lib/YANLib/YANDateTime.Nullable.cs

Large diffs are not rendered by default.

640 changes: 640 additions & 0 deletions lib/YANLib/YANDateTime.cs

Large diffs are not rendered by default.

92 changes: 51 additions & 41 deletions lib/YANLib/YANEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ public static IEnumerable<List<T>> ChunkBySize<T, T1>(this List<T> srcs, T1 chun
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-null values from the given array <paramref name="srcs"/>.
/// Removes <see langword="null"/> values from the specified objects and returns an <see cref="IEnumerable{T}"/> containing the non-null values.
/// If the type <typeparamref name="T"/> is a class or a nullable value type, the method checks for <see langword="null"/> values and excludes them.
/// If <typeparamref name="T"/> is a non-nullable value type, the method returns all objects in the input enumerable without modification.
/// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam>
/// <param name="srcs">The array to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-null values from <paramref name="srcs"/>.</returns>
/// <typeparam name="T">The type of the objects to clean.</typeparam>
/// <param name="srcs">The objects to clean.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing the non-null values.</returns>
public static IEnumerable<T> Clean<T>(params T[] srcs)
{
if (srcs is null || srcs.Length <= 0)
Expand Down Expand Up @@ -63,11 +65,13 @@ public static IEnumerable<T> Clean<T>(params T[] srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-null values from the given <paramref name="srcs"/> <see cref="IEnumerable{T}"/>.
/// Removes <see langword="null"/> values from the specified objects and returns an <see cref="IEnumerable{T}"/> containing the non-null values.
/// If the type <typeparamref name="T"/> is a class or a nullable value type, the method checks for <see langword="null"/> values and excludes them.
/// If <typeparamref name="T"/> is a non-nullable value type, the method returns all objects in the input enumerable without modification.
/// </summary>
/// <typeparam name="T">The type of elements in the <paramref name="srcs"/> <see cref="IEnumerable{T}"/>.</typeparam>
/// <param name="srcs">The <see cref="IEnumerable{T}"/> to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-null values from <paramref name="srcs"/>.</returns>
/// <typeparam name="T">The type of the objects to clean.</typeparam>
/// <param name="srcs">The objects to clean.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing the non-null values.</returns>
public static IEnumerable<T> Clean<T>(this IEnumerable<T> srcs)
{
if (srcs is null || !srcs.Any())
Expand Down Expand Up @@ -95,12 +99,14 @@ public static IEnumerable<T> Clean<T>(this IEnumerable<T> srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-null values from the given <paramref name="srcs"/> <see cref="ICollection{T}"/>.
/// Removes <see langword="null"/> values from the specified objects and returns an <see cref="IEnumerable{T}"/> containing the non-null values.
/// If the type <typeparamref name="T"/> is a class or a nullable value type, the method checks for <see langword="null"/> values and excludes them.
/// If <typeparamref name="T"/> is a non-nullable value type, the method returns all objects in the input enumerable without modification.
/// </summary>
/// <typeparam name="T">The type of elements in the <paramref name="srcs"/> <see cref="ICollection{T}"/>.</typeparam>
/// <param name="srcs">The <see cref="ICollection{T}"/> to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-null values from <paramref name="srcs"/>.</returns>
public static IEnumerable<T> Clean<T>(this ICollection<T> srcs)
/// <typeparam name="T">The type of the objects to clean.</typeparam>
/// <param name="srcs">The objects to clean.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing the non-null values.</returns>
public static IEnumerable<T> Clean<T>(this IReadOnlyCollection<T> srcs)
{
if (srcs is null || srcs.Count <= 0)
{
Expand All @@ -127,12 +133,14 @@ public static IEnumerable<T> Clean<T>(this ICollection<T> srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-null values from the given <paramref name="srcs"/> <see cref="IList{T}"/>.
/// Removes <see langword="null"/> values from the specified objects and returns an <see cref="IEnumerable{T}"/> containing the non-null values.
/// If the type <typeparamref name="T"/> is a class or a nullable value type, the method checks for <see langword="null"/> values and excludes them.
/// If <typeparamref name="T"/> is a non-nullable value type, the method returns all objects in the input enumerable without modification.
/// </summary>
/// <typeparam name="T">The type of elements in the <paramref name="srcs"/> <see cref="IList{T}"/>.</typeparam>
/// <param name="srcs">The <see cref="IList{T}"/> to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-null values from <paramref name="srcs"/>.</returns>
public static IEnumerable<T> Clean<T>(this IList<T> srcs)
/// <typeparam name="T">The type of the objects to clean.</typeparam>
/// <param name="srcs">The objects to clean.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing the non-null values.</returns>
public static IEnumerable<T> Clean<T>(this IReadOnlyList<T> srcs)
{
if (srcs is null || srcs.Count <= 0)
{
Expand Down Expand Up @@ -161,12 +169,14 @@ public static IEnumerable<T> Clean<T>(this IList<T> srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-null values from the given <paramref name="srcs"/> <see cref="ISet{T}"/>.
/// Removes <see langword="null"/> values from the specified objects and returns an <see cref="IEnumerable{T}"/> containing the non-null values.
/// If the type <typeparamref name="T"/> is a class or a nullable value type, the method checks for <see langword="null"/> values and excludes them.
/// If <typeparamref name="T"/> is a non-nullable value type, the method returns all objects in the input enumerable without modification.
/// </summary>
/// <typeparam name="T">The type of elements in the <paramref name="srcs"/> <see cref="ISet{T}"/>.</typeparam>
/// <param name="srcs">The <see cref="ISet{T}"/> to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-null values from <paramref name="srcs"/>.</returns>
public static IEnumerable<T> Clean<T>(this ISet<T> srcs)
/// <typeparam name="T">The type of the objects to clean.</typeparam>
/// <param name="srcs">The objects to clean.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing the non-null values.</returns>
public static IEnumerable<T> Clean<T>(this IReadOnlySet<T> srcs)
{
if (srcs is null || srcs.Count <= 0)
{
Expand All @@ -193,10 +203,10 @@ public static IEnumerable<T> Clean<T>(this ISet<T> srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-empty values from the given <paramref name="srcs"/> array of strings.
/// Removes <see langword="null"/> values and empty strings from the specified enumerable of strings, and returns an <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.
/// </summary>
/// <param name="srcs">The array of strings to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-empty values from <paramref name="srcs"/>.</returns>
/// <param name="srcs">The enumerable of strings to clean.</param>
/// <returns>An <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.</returns>
public static IEnumerable<string> Clean(params string[] srcs)
{
if (srcs is null || srcs.Length <= 0)
Expand All @@ -215,10 +225,10 @@ public static IEnumerable<string> Clean(params string[] srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-empty values from the given <paramref name="srcs"/> <see cref="IEnumerable{T}"/> of strings.
/// Removes <see langword="null"/> values and empty strings from the specified enumerable of strings, and returns an <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.
/// </summary>
/// <param name="srcs">The <see cref="IEnumerable{T}"/> of strings to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-empty values from <paramref name="srcs"/>.</returns>
/// <param name="srcs">The enumerable of strings to clean.</param>
/// <returns>An <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.</returns>
public static IEnumerable<string> Clean(this IEnumerable<string> srcs)
{
if (srcs is null || !srcs.Any())
Expand All @@ -235,11 +245,11 @@ public static IEnumerable<string> Clean(this IEnumerable<string> srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-empty values from the given <paramref name="srcs"/> <see cref="ICollection{T}"/> of strings.
/// Removes <see langword="null"/> values and empty strings from the specified enumerable of strings, and returns an <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.
/// </summary>
/// <param name="srcs">The <see cref="ICollection{T}"/> of strings to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-empty values from <paramref name="srcs"/>.</returns>
public static IEnumerable<string> Clean(this ICollection<string> srcs)
/// <param name="srcs">The enumerable of strings to clean.</param>
/// <returns>An <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.</returns>
public static IEnumerable<string> Clean(this IReadOnlyCollection<string> srcs)
{
if (srcs is null || srcs.Count <= 0)
{
Expand All @@ -255,11 +265,11 @@ public static IEnumerable<string> Clean(this ICollection<string> srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-empty values from the given <paramref name="srcs"/> <see cref="IList{T}"/> of strings.
/// Removes <see langword="null"/> values and empty strings from the specified enumerable of strings, and returns an <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.
/// </summary>
/// <param name="srcs">The <see cref="IList{T}"/> of strings to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-empty values from <paramref name="srcs"/>.</returns>
public static IEnumerable<string> Clean(this IList<string> srcs)
/// <param name="srcs">The enumerable of strings to clean.</param>
/// <returns>An <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.</returns>
public static IEnumerable<string> Clean(this IReadOnlyList<string> srcs)
{
if (srcs is null || srcs.Count <= 0)
{
Expand All @@ -277,11 +287,11 @@ public static IEnumerable<string> Clean(this IList<string> srcs)
}

/// <summary>
/// Returns a new <see cref="IEnumerable{T}"/> containing only the non-empty values from the given <paramref name="srcs"/> <see cref="ISet{T}"/> of strings.
/// Removes <see langword="null"/> values and empty strings from the specified enumerable of strings, and returns an <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.
/// </summary>
/// <param name="srcs">The <see cref="ISet{T}"/> of strings to be cleaned.</param>
/// <returns>An <see cref="IEnumerable{T}"/> containing only the non-empty values from <paramref name="srcs"/>.</returns>
public static IEnumerable<string> Clean(this ISet<string> srcs)
/// <param name="srcs">The enumerable of strings to clean.</param>
/// <returns>An <see cref="IEnumerable{string}"/> containing the non-null and non-empty strings.</returns>
public static IEnumerable<string> Clean(this IReadOnlySet<string> srcs)
{
if (srcs is null || srcs.Count <= 0)
{
Expand Down
Loading

0 comments on commit 99238a2

Please sign in to comment.