Beispiel #1
0
        public bool PutOrAdd(long matchBeginTime, RegexNFAStateEntry state)
        {
            object value = schedule.Get(matchBeginTime);

            if (value == null)
            {
                schedule.Put(matchBeginTime, state);
                return(true);
            }

            if (value is RegexNFAStateEntry)
            {
                RegexNFAStateEntry         valueEntry = (RegexNFAStateEntry)value;
                IList <RegexNFAStateEntry> list       = new List <RegexNFAStateEntry>();
                list.Add(valueEntry);
                list.Add(state);
                schedule.Put(matchBeginTime, list);
            }
            else
            {
                IList <RegexNFAStateEntry> list = (IList <RegexNFAStateEntry>)value;
                list.Add(state);
            }

            return(false);
        }
Beispiel #2
0
        public bool FindRemoveAddToList(long matchBeginTime, RegexNFAStateEntry state, IList <RegexNFAStateEntry> foundStates)
        {
            object entry = schedule.Get(matchBeginTime);

            if (entry == null)
            {
                return(false);
            }
            if (entry is RegexNFAStateEntry)
            {
                RegexNFAStateEntry single = (RegexNFAStateEntry)entry;
                if (terminationStateCompare.CompareTerminationStateToEndState(state, single))
                {
                    schedule.Remove(matchBeginTime);
                    foundStates.Add(single);
                    return(true);
                }
                return(false);
            }

            var entries = (IList <RegexNFAStateEntry>)entry;
            var removed = entries.RemoveWhere(
                endState => terminationStateCompare.CompareTerminationStateToEndState(state, endState),
                endState => foundStates.Add(endState)) > 0;

            if (entries.IsEmpty())
            {
                schedule.Remove(matchBeginTime);
            }
            return(removed);
        }
Beispiel #3
0
        public static IList <RegexNFAStateEntry> RemoveEventFromState(EventBean oldEvent, IEnumerator <RegexNFAStateEntry> states)
        {
            IList <RegexNFAStateEntry> keepList = new List <RegexNFAStateEntry>();

            for (; states.MoveNext();)
            {
                RegexNFAStateEntry entry = states.Current;
                var keep = true;

                EventBean[] state = entry.EventsPerStream;
                foreach (EventBean aState in state)
                {
                    if (aState != null && aState.Equals(oldEvent))
                    {
                        keep = false;
                        break;
                    }
                }

                if (keep)
                {
                    MultimatchState[] multimatch = entry.OptionalMultiMatches;
                    if (multimatch != null)
                    {
                        foreach (MultimatchState aMultimatch in multimatch)
                        {
                            if ((aMultimatch != null) && (aMultimatch.ContainsEvent(oldEvent)))
                            {
                                keep = false;
                                break;
                            }
                        }
                    }
                }

                if (keep)
                {
                    keepList.Add(entry);
                }
            }
            return(keepList);
        }
Beispiel #4
0
        internal static EventBean[] GetMultimatchArray(int[] multimatchStreamNumToVariable, RegexNFAStateEntry state, int stream)
        {
            if (state.OptionalMultiMatches == null)
            {
                return(null);
            }
            var index        = multimatchStreamNumToVariable[stream];
            var multiMatches = state.OptionalMultiMatches[index];

            if (multiMatches == null)
            {
                return(null);
            }
            return(multiMatches.ShrinkEventArray);
        }