Beispiel #1
0
        /// <inheritdoc/>
        protected internal override void Neglect(ReadOnlySpan <Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd <Capture> trace)
        {
            if (source.Length == location)
            {
                exception = AtEnd;
                trace?.Add(exception, location);
            }
            else
            {
                switch (source[location])
                {
                case '\u000A':
                case '\u000B':
                case '\u000C':
                case '\u000D':
                case '\u0085':
                case '\u2028':
                case '\u2029':
                    exception = NoMatch;
                    trace?.Add(exception, location);
                    break;

                default:
                    exception = null;
                    trace?.Add(source[location], location++);
                    break;
                }
                location++;
            }
        }
Beispiel #2
0
 void VulLijstMetHonden(IAdd <Hond> list)
 {
     list.Add(new Hond {
         Aaibaarheid = 9
     });
     list.Add(new Hond {
         Aaibaarheid = 12
     });
 }
Beispiel #3
0
		protected internal override Boolean IsNeglectHeader(ReadOnlySpan<Char> source, Int32 location) => true; // The first char could always be the edit, so this is always true.

		/// <inheritdoc/>
		protected internal override void Neglect(ReadOnlySpan<Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd<Capture> trace) {
			if (location + String.Length > source.Length) {
				exception = AtEnd;
				trace?.Add(exception, location);
			} else if (EditDistance.Hamming(String, source.Slice(location, String.Length), Casing) > MaxEdits) {
				trace?.Add(source.Slice(location, String.Length), location);
				location += String.Length;
				exception = null;
			} else {
				exception = NoMatch;
				trace?.Add(exception, location);
			}
		}
Beispiel #4
0
 /// <inheritdoc/>
 protected internal override void Neglect(ReadOnlySpan <Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd <Capture> trace)
 {
     if (source.Length == location)
     {
         exception = NoMatch;
         trace?.Add(exception, location);
     }
     else
     {
         trace?.Add('␄', location);
         exception = null;
     }
 }
Beispiel #5
0
        void RunDictionarySizeBenchmarks(IAdd <EzDataPoint> graph, string id, string yAxis, bool perItem)
        {
            _graphConfiguration[id] = plotModel => {
                AddStandardAxes(plotModel, yAxis, 0, yMaximum: perItem ? 100 : (int?)null);
                if (perItem)
                {
                    plotModel.LegendPosition = LegendPosition.TopRight;
                }
            };
            int limit = perItem ? 9999 : 133;

            for (int size = 1; size <= limit; size += Math.Max(1, size / 8))
            {
                double factor = perItem ? 1.0 / size : 1.0;

                var dict  = FillDictionary(new Dictionary <long, long>(), size, false);
                var dictR = FillDictionary(new Dictionary <long, long>(), size, true);
                //graph.Add(new EzDataPoint { GraphId = id, Series = "Dictionary<long,long> (sequential fill)", Parameter = size, Value = CountSizeInBytes(dict, 16) * factor });
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "Dictionary<long,long>", Parameter = size, Value = CountSizeInBytes(dictR, 16) * factor
                });

                var sdictR = FillDictionary(new SortedDictionary <long, long>(), size, true);
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "SortedDictionary<long,long>", Parameter = size, Value = CountSizeInBytes(sdictR, 16) * factor
                });

                if (TestALists)
                {
                    var bdict  = FillDictionary(new BDictionary <long, long>(), size, false);
                    var bdictR = FillDictionary(new BDictionary <long, long>(), size, true);
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "BDictionary<long,long> (sequential fill)", Parameter = size, Value = bdict.CountSizeInBytes(16, 8) * factor });
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "BDictionary<long,long> (random fill)", Parameter = size, Value = bdictR.CountSizeInBytes(16, 8) * factor
                    });
                }

                if (TestOther)
                {
                    var map  = FillDictionary(new MMap <long, long>(), size, false);
                    var mapR = FillDictionary(new MMap <long, long>(), size, true);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "MMap<long,long> (sequential fill)", Parameter = size, Value = map.CountMemory(16) * factor
                    });
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "MMap<long,long> (random fill)", Parameter = size, Value = mapR.CountMemory(16) * factor
                    });
                }
            }
        }
Beispiel #6
0
        void RunListSizeBenchmarks(IAdd <EzDataPoint> graph, string id, string yAxis, bool perItem)
        {
            _graphConfiguration[id] = plotModel => {
                AddStandardAxes(plotModel, yAxis, 0, yMaximum: perItem ? 60 : (int?)null);
                if (perItem)
                {
                    plotModel.LegendPosition = LegendPosition.TopRight;
                }
            };
            int limit = perItem ? 9999 : 133;

            for (int size = 1; size <= limit; size += Math.Max(1, size / 8))
            {
                double factor = perItem ? 1.0 / size : 1.0;

                var list  = AddAtEnd(new List <long>(), size);
                var lList = AddAtEnd(new LinkedList <long>(), size);
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "List<long>", Parameter = size, Value = CountSizeInBytes(list, 8) * factor
                });
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "LinkedList<long>", Parameter = size, Value = CountSizeInBytes(lList, 8) * factor
                });

                if (TestALists)
                {
                    var alist  = AddAtEnd(new AList <long>(), size);
                    var alistR = AddAtRandom(new AList <long>(), size);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "AList<long> (sequential fill)", Parameter = size, Value = alist.CountSizeInBytes(8) * factor
                    });
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "AList<long> (random fill)", Parameter = size, Value = alistR.CountSizeInBytes(8) * factor });
                    var salist  = AddAtEnd(new SparseAList <long>(), size);
                    var salistR = AddAtRandom(new SparseAList <long>(), size);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "SparseAList<long> (sequential fill)", Parameter = size, Value = salist.CountSizeInBytes(8) * factor
                    });
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "SparseAList<long> (random fill)", Parameter = size, Value = salistR.CountSizeInBytes(8) * factor });
                }
                if (TestOther)
                {
                    var ialist  = AddAtEnd(new IndexedAList <long>(), size);
                    var ialistR = AddAtRandom(new IndexedAList <long>(), size);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "IndexedAList<long> (sequential fill)", Parameter = size, Value = ialist.CountSizeInBytes(8) * factor
                    });
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "IndexedAList<long> (random fill)", Parameter = size, Value = ialistR.CountSizeInBytes(8) * factor });
                }
            }
        }
Beispiel #7
0
 public static unsafe void Add <TElement>(this IAdd <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged
 {
     for (Int32 i = 0; i < length; i++)
     {
         collection.Add(elements[i]);
     }
 }
Beispiel #8
0
 void Add(EzDataPoint dp)
 {
     if (_where == null || _where(dp))
     {
         _graph.Add(dp);
     }
 }
Beispiel #9
0
 public static void AddAll <T>(this IAdd <T> collection, IEnumerable <T> items)
 {
     foreach (var item in items)
     {
         collection.Add(item);
     }
 }
Beispiel #10
0
 /// <summary>
 /// Adds the elements to this collection, one by one.
 /// </summary>
 /// <typeparam name="TElement">The type of the elements in the collection.</typeparam>
 /// <param name="collection">This collection.</param>
 /// <param name="elements">The elements to add.</param>
 /// <remarks>
 /// The behavior of this operation is type dependent, and no particular location in the collection should be assumed. It is further possible the type the element is added to is not a collection.
 /// </remarks>
 public static void Add <TElement>(this IAdd <TElement> collection, ReadOnlySpan <TElement> elements)
 {
     for (Int32 i = 0; i < elements.Length; i++)
     {
         collection.Add(elements[i]);
     }
 }
Beispiel #11
0
 /// <summary>
 /// Adds the elements to this collection, one by one.
 /// </summary>
 /// <typeparam name="TElement">The type of the elements in the collection.</typeparam>
 /// <typeparam name="TEnumerator">The type of the enumerator of the <paramref name="elements"/>.</typeparam>
 /// <param name="collection">This collection.</param>
 /// <param name="elements">The elements to add.</param>
 /// <remarks>
 /// The behavior of this operation is type dependent, and no particular location in the collection should be assumed. It is further possible the type the element is added to is not a collection.
 /// </remarks>
 public static void Add <TElement, TEnumerator>(this IAdd <TElement> collection, IGetEnumerator <TElement, TEnumerator>?elements) where TEnumerator : notnull, ICurrent <TElement>, IMoveNext
 {
     if (elements is not null)
     {
         foreach (TElement element in elements)
         {
             collection.Add(element);
         }
     }
 }
Beispiel #12
0
 /// <summary>
 /// Adds the elements to this collection, one by one.
 /// </summary>
 /// <typeparam name="TElement">The type of the elements in the collection.</typeparam>
 /// <param name="collection">This collection.</param>
 /// <param name="elements">The elements to add.</param>
 /// <remarks>
 /// The behavior of this operation is type dependent, and no particular location in the collection should be assumed. It is further possible the type the element is added to is not a collection.
 /// </remarks>
 public static void Add <TElement>(this IAdd <TElement> collection, Collections.Generic.IEnumerable <TElement>?elements)
 {
     if (elements is not null)
     {
         foreach (TElement element in elements)
         {
             collection.Add(element);
         }
     }
 }
        public static IAdd AddItems(IAdd addCollection, string[] input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                Console.Write(addCollection.Add(input[i]) + " ");
            }

            Console.WriteLine();

            return(addCollection);
        }
Beispiel #14
0
 public async Task <T> Add(T entity)
 {
     try
     {
         return(await _Add.Add(entity));
     }
     catch (FormatException ex)
     {
         throw new BusinessException("Error en la capa Bussines", ex);
     }
     catch (RepositoryException ex)
     {
         throw new BusinessException("Error de la capa Dao", ex);
     }
 }
Beispiel #15
0
        static void Main(string[] args)
        {
            Test t = new Test(3);

            t.Add();
            Console.WriteLine(t.n);
            Console.Beep();

            IAdd iadd = t;

            iadd.Add();
            Console.WriteLine(t.n);


            int a = int.Parse(Console.ReadLine());

            Console.WriteLine(a);
        }
Beispiel #16
0
        public static void BuildFromDatabase(string server, string db, string table, string column, IAdd t)
        {
            DuplicateDetector.Clear();
            t.BeginUpdate();
            SqlConnection connection = new SqlConnection(Util.GetConnectionString(server, db));

            connection.Open();
            string     q      = TrieQuery(db, table, column);
            SqlCommand sqlcmd = new SqlCommand(q, connection);

            sqlcmd.CommandTimeout = 0;

            int count = 0;

            using (SqlDataReader reader = sqlcmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    count++;
                    if (count == 10)
                    {
                        Console.Write("");
                        //break;
                    }
                    string s = reader.GetString(0);
                    if (DuplicateDetector.ContainsKey(s))
                    {
                        if (count % 10000 == 0)
                        {
                            Console.WriteLine("{1}: Inserted {0} records", count, DateTime.Now);
                        }
                        continue;
                    }
                    DuplicateDetector.Add(s, true);
                    t.Add(s);
                    if (count % 10000 == 0)
                    {
                        Console.WriteLine("{1}: Inserted {0} records", count, DateTime.Now);
                    }
                }
            }
            connection.Close();
            t.EndUpdate();
        }
Beispiel #17
0
        public static void BuildFromDatabase(string server, string db, string table, string column, IAdd t)
        {
            DuplicateDetector.Clear();
            t.BeginUpdate();
            SqlConnection connection = new SqlConnection(Util.GetConnectionString(server, db));
            connection.Open();
            string q = TrieQuery(db, table, column);
            SqlCommand sqlcmd = new SqlCommand(q, connection);
            sqlcmd.CommandTimeout = 0;

            int count = 0;
            using (SqlDataReader reader = sqlcmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    count++;
                    if (count == 10)
                    {
                        Console.Write("");
                        //break;
                    }
                    string s = reader.GetString(0);
                    if (DuplicateDetector.ContainsKey(s))
                    {
                        if (count % 10000 == 0)
                        {
                            Console.WriteLine("{1}: Inserted {0} records", count, DateTime.Now);
                        }
                        continue;
                    }
                    DuplicateDetector.Add(s, true);
                    t.Add(s);
                    if (count % 10000 == 0)
                    {
                        Console.WriteLine("{1}: Inserted {0} records", count, DateTime.Now);
                    }
                }
            }
            connection.Close();
            t.EndUpdate();
        }
Beispiel #18
0
        /// <inheritdoc/>
        protected internal override void Consume(ReadOnlySpan <Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd <Capture> trace)
        {
            if (source.Length == location)
            {
                exception = AtEnd;
                trace?.Add(exception, location);
            }
            else
            {
                exception = null;
                switch (source[location])
                {
                case '\u000A':
                    if (location + 1 < source.Length && source[location + 1] == '\u000D')
                    {
                        trace?.Add(source.Slice(location, 2), location);
                        location++;
                    }
                    else
                    {
                        trace?.Add('\u000A', location);
                    }
                    break;

                case '\u000B':
                    trace?.Add('\u000B', location);
                    break;

                case '\u000C':
                    trace?.Add('\u000C', location);
                    break;

                case '\u000D':
                    if (location + 1 < source.Length && source[location + 1] == '\u000A')
                    {
                        trace?.Add(source.Slice(location, 2), location);
                        location++;
                    }
                    else
                    {
                        trace?.Add('\u000D', location);
                    }
                    break;

                case '\u0085':
                    trace?.Add('\u0085', location);
                    break;

                case '\u2028':
                    trace?.Add('\u2028', location);
                    break;

                case '\u2029':
                    trace?.Add('\u2029', location);
                    break;

                default:
                    exception = NoMatch;
                    trace?.Add(exception, location);
                    return;
                }
                location++;
            }
        }
Beispiel #19
0
 public int Foo(int c)
 {
     IAdd adder = (IAdd) this;
     return adder.Add(c);
 }        
Beispiel #20
0
            void AddTag(int startIndex, int length, ClassificationTag tag)
            {
                var sspan = new SnapshotSpan(_file.TextSnapshot, new Span(startIndex, length));

                _results.Add(new TagSpan <ClassificationTag>(sspan, tag));
            }
Beispiel #21
0
 /// <summary>
 /// Adds the elements to this collection, one by one.
 /// </summary>
 /// <param name="collection">This collection.</param>
 /// <param name="elements">The elements to add.</param>
 /// <remarks>
 /// The behavior of this operation is type dependent, and no particular location in the collection should be assumed. It is further possible the type the element is added to is not a collection.
 /// </remarks>
 public static void Add(this IAdd <Char> collection, String?elements) => collection.Add(elements.AsSpan());