private bool ForEachConstraintRecursively(IFunction4 block) { IQueue4 queue = new NoDuplicatesQueue(new NonblockingQueue()); IEnumerator constrIter = IterateConstraints(); while (constrIter.MoveNext()) { queue.Add(constrIter.Current); } while (queue.HasNext()) { QCon constr = (QCon)queue.Next(); bool cancel = (bool)block.Apply(constr); if (cancel) { return(true); } IEnumerator childIter = constr.IterateChildren(); while (childIter.MoveNext()) { queue.Add(childIter.Current); } IEnumerator joinIter = constr.IterateJoins(); while (joinIter.MoveNext()) { queue.Add(joinIter.Current); } } return(false); }
public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard ) { _calls++; IFunction4 delegateProducer = new _IFunction4_26(this, producer); return _delegate.Produce(key, delegateProducer, onDiscard); }
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(); } }
private object AsTopLevelCall(IFunction4 block, Transaction trans) { trans = CheckTransaction(trans); BeginTopLevelCall(); try { return(block.Apply(trans)); } catch (Db4oRecoverableException exc) { throw; } catch (SystemException exc) { throw; } catch (Exception exc) { FatalShutdown(exc); } finally { EndTopLevelCall(); } // should never happen - just to make compiler happy throw new Db4oException(); }
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]); }
private CachingBin.Page GetPage(long startAddress, IFunction4 producer) { CachingBin.Page page = ((CachingBin.Page)_cache.Produce(PageAddressFor(startAddress ), producer, _onDiscardPage)); page.EnsureEndAddress(_fileLength); return(page); }
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]; }
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); }
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; }
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; }
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); }
public SequentialIdGenerator(IFunction4 findFreeId, int initialValue, int minValidId , int maxValidId) { _findFreeId = findFreeId; _minValidId = minValidId; _maxValidId = maxValidId; InitializeGenerator(initialValue); }
public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard ) { _calls++; IFunction4 delegateProducer = new _IFunction4_26(this, producer); return(_delegate.Produce(key, delegateProducer, onDiscard)); }
public FunctionApplicationIterator(IEnumerator iterator, IFunction4 function) : base (iterator) { if (null == function) { throw new ArgumentNullException(); } _function = function; }
/// <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(); }
private static object WithContainer(string filename, IFunction4 block) { IObjectContainer container = Db4oFactory.OpenFile(filename); try { return block.Apply(container); } finally { container.Close(); } }
private static object WithContainer(string filename, IFunction4 block) { IObjectContainer container = Db4oFactory.OpenFile(filename); try { return(block.Apply(container)); } finally { container.Close(); } }
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; }
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); } var value = producer.Apply(((long)key)); _slots[((long)key)] = value; _a1.AddFirst((((long)key))); return(value); }
private void ReclaimFor(object key, IFunction4 producer, IProcedure4 finalizer) { if (_slots.Count < _maxSize) { _slots[key] = producer.Apply(key); return; } if (_a1in.Size() > _inSize) { var lastKey = _a1in.RemoveLast(); Discard(lastKey, finalizer); if (_a1out.IsFull()) { _a1out.RemoveLast(); } _a1out.AddFirst(lastKey); } else { var lastKey = _am.RemoveLast(); Discard(lastKey, finalizer); } _slots[key] = producer.Apply(key); }
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); }
private IEnumerator MapPersistentFields(object obj, IFunction4 function) { return(Iterators.Map(IteratePersistentFields(obj), function)); }
public ITest Transmogrify(IFunction4 fun) { return (ITest) fun.Apply(this); }
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); }
private void InitializeConstructor(ITypeHandler4 customTypeHandler) { if (IsTransient()) { _container.LogMsg(23, GetName()); SetStateDead(); return; } if (IsInterface() || IsAbstract()) { return; } var constructor = CreateConstructor(customTypeHandler); if (constructor != null) { _constructor = constructor; return; } NotStorable(); }
public TestPuppet() { producer = new _IFunction4_50(this); }
public virtual object Produce(object key, IFunction4 producer, IProcedure4 onDiscard ) { return(producer.Apply(key)); }
/// <summary> /// Returns a new iterator which yields the result of applying the function /// to every element in the original iterator. /// </summary> /// <remarks> /// Returns a new iterator which yields the result of applying the function /// to every element in the original iterator. /// <see cref="Skip">Skip</see> /// can be returned from function to indicate the current /// element should be skipped. /// </remarks> /// <param name="iterator"></param> /// <param name="function"></param> /// <returns></returns> public static IEnumerator Map(IEnumerator iterator, IFunction4 function) { return(new FunctionApplicationIterator(iterator, function)); }
public static IEnumerable Map(IEnumerable iterable, IFunction4 function) { return new _IEnumerable_253(iterable, function); }
public static IEnumerable Series(object seed, IFunction4 function) { return new _IEnumerable_356(seed, function); }
private IEnumerator MapPersistentFields(object obj, IFunction4 function) { return Iterators.Map(IteratePersistentFields(obj), function); }
/// <summary> /// Returns a new iterator which yields the result of applying the function /// to every element in the original iterator. /// </summary> /// <remarks> /// Returns a new iterator which yields the result of applying the function /// to every element in the original iterator. /// <see cref="Skip">Skip</see> /// can be returned from function to indicate the current /// element should be skipped. /// </remarks> /// <param name="iterator"></param> /// <param name="function"></param> /// <returns></returns> public static IEnumerator Map(IEnumerator iterator, IFunction4 function) { return new FunctionApplicationIterator(iterator, function); }
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); }
public static IEnumerator Map(System.Array array, IFunction4 function) { return(Map(array.GetEnumerator(), function)); }
public static IEnumerator Map(object[] array, IFunction4 function) { return(Map(new ArrayIterator4(array), function)); }
public _IEnumerator_358(object seed, IFunction4 function) { this.seed = seed; this.function = function; this._current = seed; }
public object Produce(object key, IFunction4 producer, IProcedure4 onDiscard) { Record("Produce", key); return producer.Apply(key); }
public _IFunction4_26(CacheStatistics _enclosing, IFunction4 producer) { this._enclosing = _enclosing; this.producer = producer; }
public static IEnumerable ConcatMap(IEnumerable iterable, IFunction4 function) { return Concat(Map(iterable, function)); }
public static IEnumerable ConcatMap(IEnumerable iterable, IFunction4 function) { return(Concat(Map(iterable, function))); }
public static IEnumerator Map(object[] array, IFunction4 function) { return Map(new ArrayIterator4(array), function); }
public _IEnumerable_253(IEnumerable iterable, IFunction4 function) { this.iterable = iterable; this.function = function; }
public SequentialIdGenerator(IFunction4 findFreeId, int minValidId, int maxValidId ) : this(findFreeId, minValidId - 1, minValidId, maxValidId) { }
public _IEnumerable_356(object seed, IFunction4 function) { this.seed = seed; this.function = function; }
private object AsTopLevelStore(IFunction4 block, Transaction trans) { trans = CheckTransaction(trans); object result = AsTopLevelCall(block, trans); if (_stackDepth == 0) { trans.ProcessDeletes(); } return result; }
public virtual ITest Transmogrify(IFunction4 fun) { return ((ITest)fun.Apply(this)); }
public static IEnumerable Map(IEnumerable iterable, IFunction4 function) { return(new _IEnumerable_253(iterable, function)); }
public SodaQueryComparatorTestCase() { oidByItemId = new _IFunction4_121(this); }
virtual protected object Cache4Produce(object key, IFunction4 producer) { return(_cache4.Produce(key, producer, null)); }
public static IEnumerable Series(object seed, IFunction4 function) { return(new _IEnumerable_356(seed, function)); }
public virtual ITest Transmogrify(IFunction4 fun) { return((ITest)fun.Apply(this)); }