daily update on 20250127 by nitload youmu, schema and element splitter complete, builtin defination building

This commit is contained in:
Nitload
2025-01-28 08:52:16 +08:00
parent 190d67a034
commit e687473132
134 changed files with 17949 additions and 867 deletions
@@ -0,0 +1,59 @@
using StgSharp.Graphics.OpenGL;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Commom.Collections
{
public interface IPoolable
{
public int ID { get; }
}
public class CacheIndexPool<T> : IEnumerable<T> where T : IPoolable
{
private ConcurrentDictionary<int, T> _cache;
private Func<T> _defaultCreater;
public CacheIndexPool(Func<T> defaultCreater)
{
_cache = new ConcurrentDictionary<int, T>();
_defaultCreater = defaultCreater;
}
public T this[int index]
{
get
{
if (_cache.TryGetValue(index, out T value))
{
return value;
}
T newValue = _defaultCreater();
_cache.TryAdd(index, newValue);
return newValue;
}
}
public IEnumerator<T> GetEnumerator()
{
return _cache.Values.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public T CreateObject()
{
T _new = _defaultCreater();
_cache.AddOrUpdate(1, _new,static (_,origin)=>origin);
throw new NotImplementedException();
return _new;
}
}
}