本文整理汇总了C#中IFunction4类的典型用法代码示例。如果您正苦于以下问题:C# IFunction4类的具体用法?C# IFunction4怎么用?C# IFunction4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFunction4类属于命名空间,在下文中一共展示了IFunction4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Produce
public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
)
{
if (key == null)
{
throw new ArgumentNullException();
}
if (_am.Remove(key))
{
_am.AddFirst(key);
return _slots[key];
}
if (_a1out.Contains(key))
{
ReclaimFor(key, producer, finalizer);
_am.AddFirst(key);
return _slots[key];
}
if (_a1in.Contains(key))
{
return _slots[key];
}
ReclaimFor(key, producer, finalizer);
_a1in.AddFirst(key);
return _slots[key];
}
示例2: Produce
public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
)
{
if (key == null)
{
throw new ArgumentNullException();
}
if (_am.Remove(key))
{
_am.AddFirst(key);
return _slots[key];
}
if (_a1.Remove(key))
{
_am.AddFirst(key);
return _slots[key];
}
if (_slots.Count >= _maxSize)
{
DiscardPage(finalizer);
}
object value = producer.Apply(key);
_slots[key] = value;
_a1.AddFirst(key);
return value;
}
示例3: Produce
public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard
)
{
_calls++;
IFunction4 delegateProducer = new _IFunction4_26(this, producer);
return _delegate.Produce(key, delegateProducer, onDiscard);
}
示例4: Produce
public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
)
{
object value = _slots[key];
if (value == null)
{
object newValue = producer.Apply(key);
if (newValue == null)
{
return null;
}
if (_slots.Count >= _maxSize)
{
object discarded = Sharpen.Collections.Remove(_slots, _lru.RemoveLast());
if (null != finalizer)
{
finalizer.Apply(discarded);
}
}
_slots[key] = newValue;
_lru.AddFirst(key);
return newValue;
}
_lru.Remove(key);
// O(N)
_lru.AddFirst(key);
return value;
}
示例5: SequentialIdGenerator
public SequentialIdGenerator(IFunction4 findFreeId, int initialValue, int minValidId
, int maxValidId)
{
_findFreeId = findFreeId;
_minValidId = minValidId;
_maxValidId = maxValidId;
InitializeGenerator(initialValue);
}
示例6: FunctionApplicationIterator
public FunctionApplicationIterator(IEnumerator iterator, IFunction4 function) : base
(iterator)
{
if (null == function)
{
throw new ArgumentNullException();
}
_function = function;
}
示例7: CachingBin
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
public CachingBin(IBin bin, ICache4 cache, int pageCount, int pageSize) : base(bin
)
{
_onDiscardPage = new _IProcedure4_22(this);
_producerFromDisk = new _IFunction4_138(this);
_producerFromPool = new _IFunction4_147(this);
_pageSize = pageSize;
_pagePool = new SimpleObjectPool(NewPagePool(pageCount));
_cache = cache;
_fileLength = _bin.Length();
}
示例8: WithContainer
private static object WithContainer(string filename, IFunction4 block)
{
IObjectContainer container = Db4oFactory.OpenFile(filename);
try
{
return block.Apply(container);
}
finally
{
container.Close();
}
}
示例9: Produce
public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
)
{
if (_am.Remove((((long)key))))
{
_am.AddFirst((((long)key)));
return _slots[((long)key)];
}
if (_a1.Remove((((long)key))))
{
_am.AddFirst((((long)key)));
return _slots[((long)key)];
}
if (_slots.Count >= _maxSize)
{
DiscardPage(finalizer);
}
object value = producer.Apply(((long)key));
_slots[((long)key)] = value;
_a1.AddFirst((((long)key)));
return value;
}
示例10: ReclaimFor
private void ReclaimFor(object key, IFunction4 producer, IProcedure4 finalizer)
{
if (_slots.Count < _maxSize)
{
_slots[key] = producer.Apply(key);
return;
}
if (_a1in.Size() > _inSize)
{
object lastKey = _a1in.RemoveLast();
Discard(lastKey, finalizer);
if (_a1out.IsFull())
{
_a1out.RemoveLast();
}
_a1out.AddFirst(lastKey);
}
else
{
object lastKey = _am.RemoveLast();
Discard(lastKey, finalizer);
}
_slots[key] = producer.Apply(key);
}
示例11: Series
public static IEnumerable Series(object seed, IFunction4 function)
{
return new _IEnumerable_356(seed, function);
}
示例12: _IEnumerable_253
public _IEnumerable_253(IEnumerable iterable, IFunction4 function)
{
this.iterable = iterable;
this.function = function;
}
示例13: Map
public static IEnumerable Map(IEnumerable iterable, IFunction4 function)
{
return new _IEnumerable_253(iterable, function);
}
示例14: MapPersistentFields
private IEnumerator MapPersistentFields(object obj, IFunction4 function)
{
return Iterators.Map(IteratePersistentFields(obj), function);
}
示例15: Transmogrify
public virtual ITest Transmogrify(IFunction4 fun)
{
return ((ITest)fun.Apply(this));
}