当前位置: 首页>>代码示例>>C#>>正文


C# IFunction4.Apply方法代码示例

本文整理汇总了C#中IFunction4.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# IFunction4.Apply方法的具体用法?C# IFunction4.Apply怎么用?C# IFunction4.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFunction4的用法示例。


在下文中一共展示了IFunction4.Apply方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 (_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;
		}
开发者ID:erdincay,项目名称:db4o,代码行数:26,代码来源:LRU2QCache.cs

示例2: 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;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:28,代码来源:LRUCache.cs

示例3: 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;
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:22,代码来源:LRU2QLongCache.cs

示例4: 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);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:24,代码来源:LRU2QXCache.cs

示例5: Produce

		public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
			)
		{
			long longKey = (((long)key));
			if (_last == null)
			{
				object lastValue = producer.Apply(((long)key));
				if (lastValue == null)
				{
					return null;
				}
				_size = 1;
				LRULongCache.Entry lastEntry = new LRULongCache.Entry(longKey, lastValue);
				_slots.Put(longKey, lastEntry);
				_first = lastEntry;
				_last = lastEntry;
				return lastValue;
			}
			LRULongCache.Entry entry = (LRULongCache.Entry)_slots.Get(longKey);
			if (entry == null)
			{
				if (_size >= _maxSize)
				{
					LRULongCache.Entry oldEntry = (LRULongCache.Entry)_slots.Remove(_last._key);
					_last = oldEntry._previous;
					_last._next = null;
					if (null != finalizer)
					{
						finalizer.Apply((object)oldEntry._value);
					}
					_size--;
				}
				object newValue = producer.Apply(((long)key));
				if (newValue == null)
				{
					return null;
				}
				_size++;
				LRULongCache.Entry newEntry = new LRULongCache.Entry(longKey, newValue);
				_slots.Put(longKey, newEntry);
				_first._previous = newEntry;
				newEntry._next = _first;
				_first = newEntry;
				return newValue;
			}
			if (_first == entry)
			{
				return ((object)entry._value);
			}
			LRULongCache.Entry previous = entry._previous;
			entry._previous = null;
			if (_last == entry)
			{
				_last = previous;
			}
			previous._next = entry._next;
			if (previous._next != null)
			{
				previous._next._previous = previous;
			}
			_first._previous = entry;
			entry._next = _first;
			_first = entry;
			return ((object)entry._value);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:65,代码来源:LRULongCache.cs

示例6: Transmogrify

		public virtual ITest Transmogrify(IFunction4 fun)
		{
			return ((ITest)fun.Apply(this));
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:4,代码来源:FailingTest.cs

示例7: WithDatabase

		private void WithDatabase(string file, IFunction4 function)
		{
			Configure();
			IExtObjectContainer objectContainer = Db4oFactory.OpenFile(file).Ext();
			try
			{
				function.Apply(objectContainer);
			}
			finally
			{
				objectContainer.Close();
			}
			IObjectServer server = Db4oFactory.OpenServer(ClientServerFileName(file), -1);
			server.GrantAccess(Username, Password);
			objectContainer = Db4oFactory.OpenClient("localhost", server.Ext().Port(), Username
				, Password).Ext();
			try
			{
				function.Apply(objectContainer);
			}
			finally
			{
				objectContainer.Close();
				server.Close();
			}
		}
开发者ID:superyfwy,项目名称:db4o,代码行数:26,代码来源:FormatMigrationTestCaseBase.cs

示例8: Produce

 public object Produce(object key, IFunction4 producer, IProcedure4 onDiscard)
 {
     Record("Produce", key);
     return producer.Apply(key);
 }
开发者ID:masroore,项目名称:db4o,代码行数:5,代码来源:GenericCacheFactoryTestCase.cs

示例9: Transmogrify

		public ITest Transmogrify(IFunction4 fun) 
		{
			return (ITest) fun.Apply(this);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:4,代码来源:VerifyAssemblyTest.cs

示例10: WithContainer

 private static object WithContainer(string filename, IFunction4 block)
 {
     var container = Db4oFactory.OpenFile(filename);
     try
     {
         return block.Apply(container);
     }
     finally
     {
         container.Close();
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:12,代码来源:MigrationHopsTestCase.cs

示例11: Produce

 public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard
     )
 {
     return producer.Apply(key);
 }
开发者ID:masroore,项目名称:db4o,代码行数:5,代码来源:NullCache4.cs

示例12: ForEachConstraintRecursively

 private bool ForEachConstraintRecursively(IFunction4 block)
 {
     IQueue4 queue = new NoDuplicatesQueue(new NonblockingQueue());
     var constrIter = IterateConstraints();
     while (constrIter.MoveNext())
     {
         queue.Add(constrIter.Current);
     }
     while (queue.HasNext())
     {
         var constr = (QCon) queue.Next();
         var cancel = (bool) block.Apply(constr);
         if (cancel)
         {
             return true;
         }
         var childIter = constr.IterateChildren();
         while (childIter.MoveNext())
         {
             queue.Add(childIter.Current);
         }
         var joinIter = constr.IterateJoins();
         while (joinIter.MoveNext())
         {
             queue.Add(joinIter.Current);
         }
     }
     return false;
 }
开发者ID:masroore,项目名称:db4o,代码行数:29,代码来源:QQueryBase.cs

示例13: Produce

 public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
     )
 {
     var intKey = (((int) key));
     if (_last == null)
     {
         var lastValue = producer.Apply(((int) key));
         if (lastValue == null)
         {
             return null;
         }
         _size = 1;
         var lastEntry = new Entry(intKey, lastValue);
         _slots.Put(intKey, lastEntry);
         _first = lastEntry;
         _last = lastEntry;
         return lastValue;
     }
     var entry = (Entry) _slots.Get(intKey);
     if (entry == null)
     {
         if (_size >= _maxSize)
         {
             var oldEntry = (Entry) _slots.Remove(_last._key);
             _last = oldEntry._previous;
             _last._next = null;
             if (null != finalizer)
             {
                 finalizer.Apply(oldEntry._value);
             }
             _size--;
         }
         var newValue = producer.Apply(((int) key));
         if (newValue == null)
         {
             return null;
         }
         _size++;
         var newEntry = new Entry(intKey, newValue);
         _slots.Put(intKey, newEntry);
         _first._previous = newEntry;
         newEntry._next = _first;
         _first = newEntry;
         return newValue;
     }
     if (_first == entry)
     {
         return entry._value;
     }
     var previous = entry._previous;
     entry._previous = null;
     if (_last == entry)
     {
         _last = previous;
     }
     previous._next = entry._next;
     if (previous._next != null)
     {
         previous._next._previous = previous;
     }
     _first._previous = entry;
     entry._next = _first;
     _first = entry;
     return entry._value;
 }
开发者ID:masroore,项目名称:db4o,代码行数:65,代码来源:LRUIntCache.cs


注:本文中的IFunction4.Apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。