Izayoi.Data.Packs 1.0.0

dotnet add package Izayoi.Data.Packs --version 1.0.0                
NuGet\Install-Package Izayoi.Data.Packs -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Izayoi.Data.Packs" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Izayoi.Data.Packs --version 1.0.0                
#r "nuget: Izayoi.Data.Packs, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Izayoi.Data.Packs as a Cake Addin
#addin nuget:?package=Izayoi.Data.Packs&version=1.0.0

// Install Izayoi.Data.Packs as a Cake Tool
#tool nuget:?package=Izayoi.Data.Packs&version=1.0.0                

Izayoi.Data.Packs

This is a struct pack.

Structures

Structure Cateogory Remarks
ComparableStructPack<TValue1, TValue2> comparable A comparable struct pack.
ComparableStructPack<TValue1, TValue2, TValue3> comparable A comparable struct pack.
ComparableStructPack<TValue1, TValue2, TValue3, TValue4> comparable A comparable struct pack.
ComparableStructPack<TValue1, TValue2, TValue3, TValue4, TValue5> comparable A comparable struct pack.
UncomparableStructPack<TValue1, TValue2> uncomarable A uncomparable struct pack.
UncomparableStructPack<TValue1, TValue2, TValue3> uncomarable A uncomparable struct pack.
UncomparableStructPack<TValue1, TValue2, TValue3, TValue4> uncomarable A uncomparable struct pack.
UncomparableStructPack<TValue1, TValue2, TValue3, TValue4, TValue5> uncomarable A uncomparable struct pack.

Examples

ComparableStructPack

using Izayoi.Data.Comparable;
using Izayoi.Data.Packs;
using System;

public class Example
{
    public void Method1()
    {
        ComparableStructPack<int, int> csp2 = new(1, 2);

        ComparableStructPack<int, long, int> csp3 = new(1, 2, 3);

        ComparableStructPack<int, byte, byte, short> csp4 = new(1, 2, 3, 4);

        ComparableStructPack<int, byte, byte, short, long> csp5 = new(1, 2, 3, 4, 5);

        // csp5.Value1: 1
        // csp5.Value2: 2
        // csp5.Value3: 3
        // csp5.Value4: 4
        // csp5.Value5: 5

        (int value1, long value2, int value3) = csp3;

        // value1: 1, value2: 2, value3: 3
    }

    public void Method2()
    {
        ComparableStructPack<int, int> csp1 = new(1, 2);
        ComparableStructPack<int, int> csp2 = new(1, 2);

        if (csp1 == csp2)
        {
            // true
        }
    }

    public void Method3()
    {
        ComparableStructPack<int, int> csp00 = new(0, 0);
        ComparableStructPack<int, int> csp01 = new(0, 1);
        ComparableStructPack<int, int> csp10 = new(1, 0);
        ComparableStructPack<int, int> csp11 = new(1, 1);

        if (csp00 < csp01)
        {
            // true
        }

        // csp00 < csp01 < csp10 < csp11
    }

    public void Method4()
    {
        ComparableStructPack<int, bool> csp0f = new(0, false);

        ComparableStructPack<int, bool> csp0t = new(0, true);

        ComparableStructPack<int, bool> csp1f = new(1, false);

        ComparableStructPack<int, bool> csp1t = new(1, true);

        if (csp0f < csp0t)
        {
            // true (false < true)
        }

        // csp0f < csp0t < csp1f < csp1t
    }

    // Izayoi.Data.Comparable.ComparableNullable<TValue>
    public void Method5()
    {
        // NG
        //ComparableStructPack<int, int?> csp1n = new(1, null);

        // NG
        //ComparableStructPack<int, System.Nullable<int>> csp1n = new(1, null);

        // OK
        ComparableStructPack<int, ComparableNullable<int>> csp1n = new(1, null);

        ComparableStructPack<int, ComparableNullable<int>> csp1m1 = new(1, -1);

        ComparableStructPack<int, ComparableNullable<int>> csp10 = new(1, 0);

        ComparableStructPack<int, ComparableNullable<int>> csp11 = new(1, 1);

        ComparableStructPack<int, ComparableNullable<int>> csp2n = new(2, null);

        if (csp1n < csp1m1)
        {
            // true (null < -1)
        }

        // csp1n < csp1m1 < csp10 < csp11 < csp2n
    }

    public void Method6()
    {
        ComparableStructPack<int, ComparableSample2Struct> csp123 = new(1, new(2, 3));

        ComparableStructPack<int, ComparableSample2Struct> csp124 = new(1, new(2, 4));

        if (csp123 < csp124)
        {
            // true
        }
    }
}

public readonly struct ComparableSample2Struct :
    IComparable<ComparableSample2Struct>,
    IEquatable<ComparableSample2Struct>
{
    private readonly int value1;

    private readonly int value2;

    public ComparableSample2Struct(int value1, int value2)
    {
        this.value1 = value1;
        this.value2 = value2;
    }

    public readonly int Value1 => value1;

    public readonly int Value2 => value2;

    public int CompareTo(ComparableSample2Struct other)
    {
        //if (other is null)
        //{
        //    return 1;
        //}

        int compared1 = Value1.CompareTo(other.Value1);

        if (compared1 != 0)
        {
            return compared1;
        }

        int compared2 = Value2.CompareTo(other.Value2);

        if (compared2 != 0)
        {
            return compared2;
        }

        return 0;
    }

    public bool Equals(ComparableSample2Struct other)
    {
        //if (other is null)
        //{
        //    return false;
        //}

        return
            Value1.Equals(other.Value1) &&
            Value2.Equals(other.Value2);
    }
}

UncomparableStructPack

using Izayoi.Data.Packs;
using System;

public class Example
{
    public void Method1()
    {
        UncomparableStructPack<int, int> usp2 = new(1, 2);

        UncomparableStructPack<int, long, int> usp3 = new(1, 2, 3);

        UncomparableStructPack<int, byte, byte, short> usp4 = new(1, 2, 3, 4);

        UncomparableStructPack<int, byte, byte, short, long> usp5 = new(1, 2, 3, 4, 5);

        // usp5.Value1: 1
        // usp5.Value2: 2
        // usp5.Value3: 3
        // usp5.Value4: 4
        // usp5.Value5: 5

        (int value1, long value2, int value3) = usp3;

        // value1: 1, value2: 2, value3: 3
    }

    public void Method2()
    {
        UncomparableStructPack<int, int> usp1 = new(1, 2);

        UncomparableStructPack<int, int> usp2 = new(1, 2);

        if (usp1 == usp2)
        {
            // true
        }
    }

    public void Method2()
    {
        UncomparableStructPack<int, UncomparableSample2Struct> usp1 = new(1, new(2, 3));

        UncomparableStructPack<int, UncomparableSample2Struct> usp2 = new(1, new(2, 3));

        if (usp1 == usp2)
        {
            // true
        }
    }
}

public readonly struct UncomparableSample2Struct
{
    private readonly int value1;

    private readonly int value2;

    public UncomparableSample2Struct(int value1, int value2)
    {
        this.value1 = value1;
        this.value2 = value2;
    }

    public readonly int Value1 => value1;

    public readonly int Value2 => value2;
}

Applies to

Product Versions
.NET 8, 9
.NET Standard 2.0, 2.1
Unity 2021, 2022, 6000

Wiki

Wiki


Last updated: 1 February, 2025
Editor: Izayoi Jiichan

Copyright (C) 2025 Izayoi Jiichan. All Rights Reserved.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • .NETStandard 2.1

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 58 2/1/2025