daily update on 20250214 by nitload youmu, building syntax analysor[D[D[D[D[D[C[C[C[C[C, tough!
This commit is contained in:
@@ -52,22 +52,22 @@ namespace StgSharp.Commom.Collections
|
||||
{
|
||||
|
||||
private ConcurrentDictionary<int, T> _cache;
|
||||
private Func<T> _defaultCreater;
|
||||
private Func<T> _defaultCreator;
|
||||
|
||||
public CacheIndexPool( Func<T> defaultCreater )
|
||||
public CacheIndexPool( Func<T> defaultCreator )
|
||||
{
|
||||
_cache = new ConcurrentDictionary<int, T>();
|
||||
_defaultCreater = defaultCreater;
|
||||
_defaultCreator = defaultCreator;
|
||||
}
|
||||
|
||||
public T this[ int index ]
|
||||
{
|
||||
get
|
||||
{
|
||||
if( _cache.TryGetValue( index, out T value ) ) {
|
||||
if( _cache.TryGetValue( index, out T? value ) ) {
|
||||
return value;
|
||||
}
|
||||
T newValue = _defaultCreater();
|
||||
T newValue = _defaultCreator();
|
||||
_cache.TryAdd( index, newValue );
|
||||
return newValue;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace StgSharp.Commom.Collections
|
||||
|
||||
public T CreateObject()
|
||||
{
|
||||
T _new = _defaultCreater();
|
||||
T _new = _defaultCreator();
|
||||
_cache.AddOrUpdate( 1, _new, static( _, origin ) => origin );
|
||||
throw new NotImplementedException();
|
||||
return _new;
|
||||
|
||||
Reference in New Issue
Block a user