예제 #1
0
        public virtual object Purge(object key)
        {
            int intKey = (((int)key));

            LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Remove(intKey);
            if (entry == null)
            {
                return(null);
            }
            _size--;
            if (_first == entry)
            {
                _first = entry._next;
            }
            if (_last == entry)
            {
                _last = entry._previous;
            }
            if (entry._previous != null)
            {
                entry._previous._next = entry._next;
            }
            if (entry._next != null)
            {
                entry._next._previous = entry._previous;
            }
            return((object)entry._value);
        }
예제 #2
0
 public bool MoveNext()
 {
     if (this._cursor == null)
     {
         this._current = null;
         return(false);
     }
     this._current = this._cursor;
     this._cursor  = this._cursor._next;
     return(true);
 }
예제 #3
0
        public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
                                      )
        {
            int intKey = (((int)key));

            if (_last == null)
            {
                object lastValue = producer.Apply(((int)key));
                if (lastValue == null)
                {
                    return(null);
                }
                _size = 1;
                LRUIntCache.Entry lastEntry = new LRUIntCache.Entry(intKey, lastValue);
                _slots.Put(intKey, lastEntry);
                _first = lastEntry;
                _last  = lastEntry;
                return(lastValue);
            }
            LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Get(intKey);
            if (entry == null)
            {
                if (_size >= _maxSize)
                {
                    LRUIntCache.Entry oldEntry = (LRUIntCache.Entry)_slots.Remove(_last._key);
                    _last       = oldEntry._previous;
                    _last._next = null;
                    if (null != finalizer)
                    {
                        finalizer.Apply((object)oldEntry._value);
                    }
                    _size--;
                }
                object newValue = producer.Apply(((int)key));
                if (newValue == null)
                {
                    return(null);
                }
                _size++;
                LRUIntCache.Entry newEntry = new LRUIntCache.Entry(intKey, newValue);
                _slots.Put(intKey, newEntry);
                _first._previous = newEntry;
                newEntry._next   = _first;
                _first           = newEntry;
                return(newValue);
            }
            if (_first == entry)
            {
                return((object)entry._value);
            }
            LRUIntCache.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);
        }
예제 #4
0
 public void Reset()
 {
     this._cursor  = this._enclosing._first;
     this._current = null;
 }
예제 #5
0
		public virtual object Produce(object key, IFunction4 producer, IProcedure4 finalizer
			)
		{
			int intKey = (((int)key));
			if (_last == null)
			{
				object lastValue = producer.Apply(((int)key));
				if (lastValue == null)
				{
					return null;
				}
				_size = 1;
				LRUIntCache.Entry lastEntry = new LRUIntCache.Entry(intKey, lastValue);
				_slots.Put(intKey, lastEntry);
				_first = lastEntry;
				_last = lastEntry;
				return lastValue;
			}
			LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Get(intKey);
			if (entry == null)
			{
				if (_size >= _maxSize)
				{
					LRUIntCache.Entry oldEntry = (LRUIntCache.Entry)_slots.Remove(_last._key);
					_last = oldEntry._previous;
					_last._next = null;
					if (null != finalizer)
					{
						finalizer.Apply((object)oldEntry._value);
					}
					_size--;
				}
				object newValue = producer.Apply(((int)key));
				if (newValue == null)
				{
					return null;
				}
				_size++;
				LRUIntCache.Entry newEntry = new LRUIntCache.Entry(intKey, newValue);
				_slots.Put(intKey, newEntry);
				_first._previous = newEntry;
				newEntry._next = _first;
				_first = newEntry;
				return newValue;
			}
			if (_first == entry)
			{
				return ((object)entry._value);
			}
			LRUIntCache.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);
		}
예제 #6
0
		public virtual object Purge(object key)
		{
			int intKey = (((int)key));
			LRUIntCache.Entry entry = (LRUIntCache.Entry)_slots.Remove(intKey);
			if (entry == null)
			{
				return null;
			}
			_size--;
			if (_first == entry)
			{
				_first = entry._next;
			}
			if (_last == entry)
			{
				_last = entry._previous;
			}
			if (entry._previous != null)
			{
				entry._previous._next = entry._next;
			}
			if (entry._next != null)
			{
				entry._next._previous = entry._previous;
			}
			return ((object)entry._value);
		}
예제 #7
0
			public void Reset()
			{
				this._cursor = this._enclosing._first;
				this._current = null;
			}
예제 #8
0
			public bool MoveNext()
			{
				if (this._cursor == null)
				{
					this._current = null;
					return false;
				}
				this._current = this._cursor;
				this._cursor = this._cursor._next;
				return true;
			}