internal int RemoveExpiredValues() { int numItemsRemoved = 0; try { var node = _doubleLinkedList.First; while (node != null) { var nextNode = node.Next; if (node.Value.ExpirationTime < DateTime.UtcNow) { _doubleLinkedList.Remove(node); if (_map.TryRemove(node.Value.Key, out var cacheItem)) { OnItemRemoved?.Invoke(cacheItem.Value); } numItemsRemoved++; } node = nextNode; } } catch (ObjectDisposedException ex) { LogHelper.LogWarning(LogHelper.FormatInvariant(LogMessages.IDX10902, nameof(RemoveExpiredValues), ex)); } return(numItemsRemoved); }
private void OnItemRemovedEvent() { if (Item.IsAir) { OnItemRemoved?.Invoke(this); } }
private void Source_CollectionChanged(object aSender, NotifyCollectionChangedEventArgs aArgs) { switch (aArgs.Action) { case NotifyCollectionChangedAction.Add: //CheckOneOrNone(aArgs.NewItems); OnItemAdded?.Invoke(Source, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]); break; case NotifyCollectionChangedAction.Move: //CheckOneOrNone(aArgs.NewItems); OnItemMoved?.Invoke(Source, aArgs.OldStartingIndex, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]); break; case NotifyCollectionChangedAction.Remove: //CheckOneOrNone(aArgs.OldItems); OnItemRemoved?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0]); break; case NotifyCollectionChangedAction.Replace: //CheckOneOrNone(aArgs.NewItems); OnItemReplaced?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0], (T)aArgs.NewItems[0]); break; case NotifyCollectionChangedAction.Reset: OnCleared?.Invoke(Source); break; default: throw new NotImplementedException(); } }
public void Remove(TKey key) { var value = _dictionary[key]; _dictionary.Remove(key); OnItemRemoved?.Invoke(key, value); }
public void RemoveItem(ItemInstance item) { if (_items.Remove(item)) { UpdateItemsView(); OnItemRemoved?.Invoke(item); } }
public void Remove(Item _item) { Items.Remove(_item); if (OnItemRemovedCallBack != null) { OnItemRemovedCallBack.Invoke(_item); } }
void OnTriggerExit(Collider other) { OnItemRemoved.Invoke(ItemInstance.data, groupId, null); ItemInstance.isInSlot = false; ItemInstance.transform.SetParent(null); highlightRenderer.enabled = false; ItemInstance = null; }
public void Remove(Item item) { items.Remove(item); if (onItemRemovedCallback != null) { onItemRemovedCallback.Invoke(item); } }
public void RemoveItem(int index) { Items[index].UpdateTower(null); AllEffects.RemoveWhere(effect => effect.Item == Items[index]); Items.RemoveAt(index); UpdateStats(); OnItemRemoved?.Invoke(this, index); }
public void Remove(int slotNum, Item item) { //bool값을 하나 두고 그것이 트루일때 슬롯을 안보이게 만들어버림// if (OnitemRemoveCallback != null) { OnitemRemoveCallback.Invoke(slotNum); } }
protected override void RemoveItem(int index) { var removedItem = this[index]; base.RemoveItem(index); OnItemRemoved?.Invoke(this, new ItemRemovedEventArgs <T>(removedItem)); }
public void Remove(T item) { if (!content.Contains(item)) { return; } content.Remove(item); OnItemRemoved?.Invoke(item); }
public bool Remove(IContainable item) { if (Contents.Remove(item)) { OnItemRemoved?.Invoke(this, EventArgs.Empty); return(true); } return(false); }
public bool Remove(string deviceKey) { var result = _cameraCollection.TryRemove(deviceKey, out Camera camera); if (result) { OnItemRemoved?.Invoke(this, camera); } return(result); }
public void RemoveItem(Item itemToRemove) { if (Items.Contains(itemToRemove) == false) { Debug.Log(itemToRemove.Name + " can't be found"); return; } Items.Remove(itemToRemove); OnItemRemoved?.Invoke(itemToRemove); }
public bool Remove(string id) { bool isRemoved = false; if (Items.TryGetValue(id, out T item)) { isRemoved = Items.Remove(id); OnItemRemoved?.Invoke(this, item); } return(isRemoved); }
public T Remove() { T item; lock (this) { item = this[GetIndexToRemove()]; Remove(item); } OnItemRemoved?.Invoke(this, new ItemEventArgs <T>(item)); return(item); }
public void Remove(Item item) { if (!_items.Contains(item)) { Debug.LogError($"Inventory does not contain {item} ! Could not remove."); return; } _items.Remove(item); CurrentWeight -= item.itemSO.weight; OnItemRemoved?.Invoke(item); item.Drop(); }
protected void RemoveOldest() { lock (_lockObject) { if (itemList.Count > 0) { var item = itemList[0]; itemList.RemoveAt(0); OnItemRemoved?.Invoke(item, EventArgs.Empty); Move(-1); } } }
internal void RemoveLRUs() { // use the _capacity for the newCacheSize calculation in the case where the cache is experiencing overflow int currentCount = _map.Count <= _capacity ? _capacity : _map.Count; var newCacheSize = currentCount - (int)(currentCount * _compactionPercentage); while (_map.Count > newCacheSize && _doubleLinkedList.Count > 0) { var lru = _doubleLinkedList.Last; if (_map.TryRemove(lru.Value.Key, out var cacheItem)) { OnItemRemoved?.Invoke(cacheItem.Value); } _doubleLinkedList.Remove(lru); } }
/// <summary> /// Remove the given enumeration of items from the reactive set. /// </summary> /// <param name="Items">An enumeration of items.</param> public ReactiveSet <T> Remove(IEnumerable <T> Items) { if (Items != null && Items.Any()) { lock (_Set) { var Timestamp = DateTime.Now; Items.ForEach(Item => { _Set.Remove(Item); OnItemRemoved?.Invoke(Timestamp, this, Item); }); } } return(this); }
/// <summary> /// Removes first item from the back of the buffer /// </summary> /// <returns></returns> public T PopBack() { if (IsEmpty) { throw new IndexOutOfRangeException("You cannot remove item from empty collection"); } var result = Back(); Count--; if (!IsEmpty) { IncreaseBackIndex(); } else { _frontItem = 0; _backItem = 0; } OnItemRemoved?.Invoke(this, new ItemRemovedEventArgs(false, result)); return(result); }
private void CheckForChanges() { var newState = Values.ToList(); foreach (var competition in _state) { if (newState.All(newCompetition => newCompetition.Id != competition.Id)) { OnItemRemoved?.Invoke(competition); } } foreach (var competition in newState) { if (_state.All(newCompetition => newCompetition.Id != competition.Id)) { OnItemAdded?.Invoke(competition); } } _state = newState; }
/// Removes a particular key from the cache. public bool TryRemove(TKey key, out TValue value) { if (key == null) { throw LogHelper.LogArgumentNullException(nameof(key)); } if (!_map.TryGetValue(key, out var cacheItem)) { value = default; return(false); } value = cacheItem.Value; _eventQueue.Add(() => _doubleLinkedList.Remove(cacheItem)); if (_map.TryRemove(key, out cacheItem)) { OnItemRemoved?.Invoke(cacheItem.Value); return(true); } return(false); }
/// <summary> /// Remove the given enumeration of items from the reactive set. /// </summary> /// <param name="Items">An enumeration of items.</param> public ReactiveSet <T> Set(IEnumerable <T> Items) { if (Items?.Any() == true) { lock (_Set) { var ToAdd = Items.Except(_Set).ToArray(); var ToRemove = _Set.Except(Items).ToArray(); var Timestamp = DateTime.Now; ToRemove.ForEach(Item => { _Set.Remove(Item); OnItemRemoved?.Invoke(Timestamp, this, Item); }); ToAdd.ForEach(Item => { _Set.Add(Item); OnItemAdded?.Invoke(Timestamp, this, Item); }); } } return(this); }
public void RemoveItem(Item item) { _items.Remove(item); OnItemRemoved?.Invoke(item); }
public void Remove(T item) { OnItemRemoved?.Invoke(this, new ListEventArgs("ItemRemoved event fired.", _list.Count)); _list.Remove(item); }
public void RemoveSlot(InventorySlot slot) { items.Remove(slot); OnItemRemoved?.Invoke(); }
public void ItemRemovedEvent(ItemInstance itemInstance) => OnItemRemoved?.Invoke(itemInstance);
public void RemoveAt(int id) { rules.RemoveAt(id); onElementRemoved.Invoke(id); }