private void ActOnEnd(TPayload payload, TKey key, int hash, long start, long endTime) { var matchSmall = new KHP { Hash = hash, Key = key, Payload = payload }; var item = RemoveOne(this.OpenEvents.entries[this.OpenEventsIndex].value, matchSmall, start); // and add it to the End list item.End = endTime; if (!this.ClosedEvents.entries[this.ClosedEventsIndex].value.ContainsKey(endTime)) { // For performance, we pull this out of a pool rather than consing a new one. // Make very sure to reset the object before restoring it to the pool, or it'll carry garbage this.dictPool.Get(out FastDictionary2 <KHP, List <ActiveEvent> > entry); this.ClosedEvents.entries[this.ClosedEventsIndex].value[endTime] = entry; } var activeEvt = ActiveEvent.FromExt(item); InsertOrAppend(this.ClosedEvents.entries[this.ClosedEventsIndex].value[endTime], matchSmall, activeEvt); }
private static ActiveEventExt RemoveOne(FastDictionary2 <KHP, List <ActiveEventExt> > events, KHP key, long startMatch) { if (!events.Lookup(key, out int indx)) { throw new InvalidOperationException("Can't remove if it's not already there!"); } var lst = events.entries[indx].value; var itemIndex = lst.FindIndex(s => s.Start == startMatch); if (itemIndex > -1) { var item = lst[itemIndex]; lst.RemoveAt(itemIndex); return(item); } throw new InvalidOperationException("Can't remove if it's not in the item list!"); }
private static ActiveEvent RemoveOne(FastDictionary2 <KHP, List <ActiveEvent> > events, KHP key) { if (!events.Lookup(key, out int indx)) { throw new InvalidOperationException("Can't remove if it's not already there!"); } var lst = events.entries[indx].value; var rv = lst[0]; lst.RemoveAt(0); return(rv); }