daily update on 20250220 by nitload youmu, building AST generator, correct type naming

This commit is contained in:
Nitload
2025-02-21 08:11:26 +08:00
parent ccef0de6f6
commit 83bde12d22
98 changed files with 4182 additions and 1855 deletions
@@ -38,58 +38,26 @@ using System.Text;
namespace StgSharp.Commom.Collections
{
public interface IPoolable
/*
public interface IPoolItem<TSignature>
{
public int ID
{
get;
init;
}
}
public class CacheIndexPool<T> : IEnumerable<T> where T: IPoolable
public class CacheIndexPool<TSignature, TItem> : IEnumerable<TItem>
where TItem: IPoolItem<TSignature>
{
private ConcurrentDictionary<int, T> _cache;
private Func<T> _defaultCreator;
public CacheIndexPool( Func<T> defaultCreator )
{
_cache = new ConcurrentDictionary<int, T>();
_defaultCreator = defaultCreator;
}
public T this[ int index ]
{
get
{
if( _cache.TryGetValue( index, out T? value ) ) {
return value;
}
T newValue = _defaultCreator();
_cache.TryAdd( index, newValue );
return newValue;
}
}
public T CreateObject()
{
T _new = _defaultCreator();
_cache.AddOrUpdate( 1, _new, static( _, origin ) => origin );
throw new NotImplementedException();
return _new;
}
public IEnumerator<T> GetEnumerator()
{
return _cache.Values.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public CacheIndexPool(
Func<TSignature>
) { }
}
/**/
}