예제 #1
0
        /// <summary>
        /// Reads the events from <paramref name="eventStream"/> into a <see cref="Collections.Generic.LinkedList"/>.
        /// The predicates associated with each event are counted and any which occur at least <paramref name="cutoff"/>
        /// times are added to the <paramref name="predicateIndex"/> dictionary along
        /// with an unique integer index.
        /// </summary>
        /// <param name="eventStream">The event stream.</param>
        /// <param name="predicateIndex">Index of the predicate.</param>
        /// <param name="cutoff">The cutoff.</param>
        /// <returns>A <see cref="Collections.Generic.LinkedList"/> of events.</returns>
        private LinkedList <Event> ComputeEventCounts(IEventStream eventStream, Dictionary <string, int> predicateIndex, int cutoff)
        {
            LinkedList <Event>        events        = new LinkedList <Event>();
            HashSet <string>          predicatesSet = new HashSet <string>();
            IDictionary <string, int> counter       = new Dictionary <string, int>();

            while (eventStream.HasNext())
            {
                Event next = eventStream.Next();
                events.AddLast(next);
                Update(next.Context, predicatesSet, counter, cutoff);
            }
            PredicateCounts = new int[predicatesSet.Count];
            int index = 0;

            HashSet <string> .Enumerator enumerator = predicatesSet.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string predicate = enumerator.Current;
                PredicateCounts[index]    = counter[predicate];
                predicateIndex[predicate] = index;
            }
            return(events);
        }
 /// <summary>
 /// Reads the events from <paramref name="eventStream"/> into a <see cref="Collections.Generic.LinkedList"/>.
 /// The predicates associated with each event are counted and any which occur at least <paramref name="cutoff"/>
 /// times are added to the <paramref name="predicateIndex"/> dictionary along
 /// with an unique integer index.
 /// </summary>
 /// <param name="eventStream">The event stream.</param>
 /// <param name="predicateIndex">Index of the predicate.</param>
 /// <param name="cutoff">The cutoff.</param>
 /// <returns>A <see cref="Collections.Generic.LinkedList"/> of events.</returns>
 private LinkedList<Event> ComputeEventCounts(IEventStream eventStream, Dictionary<string, int> predicateIndex, int cutoff)
 {
     LinkedList<Event> events = new LinkedList<Event>();
     HashSet<string> predicatesSet = new HashSet<string>();
     IDictionary<string, int> counter = new Dictionary<string, int>();
     while (eventStream.HasNext())
     {
         Event next = eventStream.Next();
         events.AddLast(next);
         Update(next.Context, predicatesSet, counter, cutoff);
     }
     PredicateCounts = new int[predicatesSet.Count];
     int index = 0;
     HashSet<string>.Enumerator enumerator = predicatesSet.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string predicate = enumerator.Current;
         PredicateCounts[index] = counter[predicate];
         predicateIndex[predicate] = index;
     }
     return events;
 }