Init
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QFSW.QC.Containers
|
||||
{
|
||||
public struct ArraySingle<T> : IReadOnlyList<T>
|
||||
{
|
||||
private readonly T _data;
|
||||
|
||||
public ArraySingle(T data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public T this[int index] => _data;
|
||||
|
||||
public int Count => 1;
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
yield return _data;
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
yield return _data;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ArraySingleExtensions
|
||||
{
|
||||
public static ArraySingle<T> AsArraySingle<T>(this T data)
|
||||
{
|
||||
return new ArraySingle<T>(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0a7bee164207c044847125f649d72e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QFSW.QC.Containers
|
||||
{
|
||||
public struct StringContainer : IReadOnlyList<char>
|
||||
{
|
||||
private readonly string _str;
|
||||
|
||||
public StringContainer(string str)
|
||||
{
|
||||
_str = str;
|
||||
}
|
||||
|
||||
public char this[int index] => _str[index];
|
||||
|
||||
public int Count => _str.Length;
|
||||
|
||||
public IEnumerator<char> GetEnumerator()
|
||||
{
|
||||
for (int i = 0; i < _str.Length; i++)
|
||||
{
|
||||
yield return _str[i];
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
for (int i = 0; i < _str.Length; i++)
|
||||
{
|
||||
yield return _str[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static implicit operator StringContainer(string str)
|
||||
{
|
||||
return new StringContainer(str);
|
||||
}
|
||||
|
||||
public static implicit operator string(StringContainer str)
|
||||
{
|
||||
return str._str;
|
||||
}
|
||||
}
|
||||
|
||||
public static class StringContainerExtensions
|
||||
{
|
||||
public static StringContainer AsIReadOnlyList(this string str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6fe5a46a82b32946a28567aefce78c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user