コード例 #1
0
            /// <summary>
            /// Revokes the given computation and deletes it from the trace
            /// </summary>
            /// <param name="traceEntry">The computation that is to be revoked</param>
            public override void RevokeEntry(ITraceEntry traceEntry)
            {
                if (traceEntry == null)
                {
                    throw new ArgumentNullException("traceEntry");
                }

                if (published.Contains(traceEntry))
                {
                    published.Remove(traceEntry);
                }
                else
                {
                    revoked.Add(traceEntry);
                }

                List <ITraceEntry> comps;

                if (computationsMade.TryGetValue(traceEntry.CreateInputArray(), out comps))
                {
                    comps.Remove(traceEntry);
                }
                if (computationsByTransformationRule.TryGetValue(traceEntry.TransformationRule, out comps))
                {
                    comps.Remove(traceEntry);
                }
            }
コード例 #2
0
ファイル: Trace.cs プロジェクト: FrederikP/NMF
        /// <summary>
        /// Publishes the given computation to the trace
        /// </summary>
        /// <param name="traceEntry">The computation that should be added to the trace</param>
        public override void PublishEntry(ITraceEntry traceEntry)
        {
            if (traceEntry == null) throw new ArgumentNullException("traceEntry");

            if (!computations.Contains(traceEntry))
            computations.Add(traceEntry);
        }
コード例 #3
0
        /// <summary>
        /// Revokes the given computation and deletes it from the trace
        /// </summary>
        /// <param name="traceEntry">The computation that is to be revoked</param>
        public override void RevokeEntry(ITraceEntry traceEntry)
        {
            if (traceEntry == null)
            {
                throw new ArgumentNullException("traceEntry");
            }

            computations.Remove(traceEntry);
        }
コード例 #4
0
 private static bool IsInputArray(ITraceEntry c, object[] input)
 {
     for (int i = 0; i < input.Length; i++)
     {
         if (!object.Equals(input[i], c.GetInput(i)))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #5
0
        /// <summary>
        /// Publishes the given computation to the trace
        /// </summary>
        /// <param name="traceEntry">The computation that should be added to the trace</param>
        public override void PublishEntry(ITraceEntry traceEntry)
        {
            if (traceEntry == null)
            {
                throw new ArgumentNullException("traceEntry");
            }

            if (!computations.Contains(traceEntry))
            {
                computations.Add(traceEntry);
            }
        }
コード例 #6
0
            /// <summary>
            /// Publishes the given computation to the trace
            /// </summary>
            /// <param name="traceEntry">The computation that should be added to the trace</param>
            public override void PublishEntry(ITraceEntry traceEntry)
            {
                if (traceEntry == null)
                {
                    throw new ArgumentNullException("traceEntry");
                }

                if (revoked.Contains(traceEntry))
                {
                    revoked.Remove(traceEntry);
                }
                else
                {
                    var success = published.Add(traceEntry);
                    if (!success)
                    {
                        return;
                    }
                }

                var box = traceEntry.CreateInputArray();
                List <ITraceEntry> comps;

                if (!computationsMade.TryGetValue(box, out comps))
                {
                    comps = new List <ITraceEntry>();
                    if (!computationsMade.TryAdd(box, comps))
                    {
                        comps = computationsMade[box];
                    }
                }
                if (!comps.Contains(traceEntry))
                {
                    comps.Add(traceEntry);
                    var rule = traceEntry.TransformationRule;
                    if (!computationsByTransformationRule.TryGetValue(rule, out comps))
                    {
                        comps = new List <ITraceEntry>();
                        if (!computationsByTransformationRule.TryAdd(rule, comps))
                        {
                            comps = computationsByTransformationRule[rule];
                        }
                    }
                    comps.Add(traceEntry);
                }
                else
                {
                    published.Remove(traceEntry);
                }
            }
コード例 #7
0
        /// <summary>
        /// Creates a new array of input elements for the given trace entry
        /// </summary>
        /// <param name="traceEntry">The current trace entry</param>
        /// <returns>A new object array containing all trace entries for this trace entry</returns>
        public static object[] CreateInputArray(this ITraceEntry traceEntry)
        {
            if (traceEntry == null)
            {
                throw new ArgumentNullException("traceEntry");
            }

            var inputTypes = traceEntry.TransformationRule.InputType;
            var array      = new object[inputTypes.Length];

            for (int i = 0; i < inputTypes.Length; i++)
            {
                array[i] = traceEntry.GetInput(i);
            }
            return(array);
        }
コード例 #8
0
 /// <summary>
 /// Publishes the given computation to the trace
 /// </summary>
 /// <param name="traceEntry">The computation that should be added to the trace</param>
 public abstract void PublishEntry(ITraceEntry traceEntry);
コード例 #9
0
 /// <summary>
 /// Revokes the given computation and deletes it from the trace
 /// </summary>
 /// <param name="traceEntry">The computation that is to be revoked</param>
 public abstract void RevokeEntry(ITraceEntry traceEntry);
コード例 #10
0
            /// <summary>
            /// Publishes the given computation to the trace
            /// </summary>
            /// <param name="traceEntry">The computation that should be added to the trace</param>
            public override void PublishEntry(ITraceEntry traceEntry)
            {
                if (traceEntry == null) throw new ArgumentNullException("traceEntry");

                if (revoked.Contains(traceEntry))
                {
                    revoked.Remove(traceEntry);
                }
                else
                {
                    var success = published.Add(traceEntry);
                    if (!success) return;
                }

                var box = traceEntry.CreateInputArray();
                List<ITraceEntry> comps;
                if (!computationsMade.TryGetValue(box, out comps))
                {
                    comps = new List<ITraceEntry>();
                    if (!computationsMade.TryAdd(box, comps))
                    {
                        comps = computationsMade[box];
                    }
                }
                if (!comps.Contains(traceEntry))
                {
                    comps.Add(traceEntry);
                    var rule = traceEntry.TransformationRule;
                    if (!computationsByTransformationRule.TryGetValue(rule, out comps))
                    {
                        comps = new List<ITraceEntry>();
                        if (!computationsByTransformationRule.TryAdd(rule, comps))
                        {
                            comps = computationsByTransformationRule[rule];
                        }
                    }
                    comps.Add(traceEntry);
                }
                else
                {
                    published.Remove(traceEntry);
                }
            }
コード例 #11
0
            /// <summary>
            /// Revokes the given computation and deletes it from the trace
            /// </summary>
            /// <param name="traceEntry">The computation that is to be revoked</param>
            public override void RevokeEntry(ITraceEntry traceEntry)
            {
                if (traceEntry == null) throw new ArgumentNullException("traceEntry");

                if (published.Contains(traceEntry))
                {
                    published.Remove(traceEntry);
                }
                else
                {
                    revoked.Add(traceEntry);
                }

                List<ITraceEntry> comps;
                if (computationsMade.TryGetValue(traceEntry.CreateInputArray(), out comps))
                {
                    comps.Remove(traceEntry);
                }
                if (computationsByTransformationRule.TryGetValue(traceEntry.TransformationRule, out comps))
                {
                    comps.Remove(traceEntry);
                }
            }
コード例 #12
0
ファイル: Trace.cs プロジェクト: FrederikP/NMF
 private static bool IsInputArray(ITraceEntry c, object[] input)
 {
     for (int i = 0; i < input.Length; i++)
     {
         if (!object.Equals(input[i], c.GetInput(i))) return false;
     }
     return true;
 }
コード例 #13
0
ファイル: Trace.cs プロジェクト: FrederikP/NMF
        /// <summary>
        /// Revokes the given computation and deletes it from the trace
        /// </summary>
        /// <param name="traceEntry">The computation that is to be revoked</param>
        public override void RevokeEntry(ITraceEntry traceEntry)
        {
            if (traceEntry == null) throw new ArgumentNullException("traceEntry");

            computations.Remove(traceEntry);
        }
コード例 #14
0
ファイル: Trace.cs プロジェクト: FrederikP/NMF
 /// <summary>
 /// Publishes the given computation to the trace
 /// </summary>
 /// <param name="traceEntry">The computation that should be added to the trace</param>
 public abstract void PublishEntry(ITraceEntry traceEntry);
コード例 #15
0
ファイル: Trace.cs プロジェクト: FrederikP/NMF
 /// <summary>
 /// Revokes the given computation and deletes it from the trace
 /// </summary>
 /// <param name="traceEntry">The computation that is to be revoked</param>
 public abstract void RevokeEntry(ITraceEntry traceEntry);