public void TrimExcess_DictionaryHasElementsChainedWithSameHashcode_Success()
        {
            var dictionary = new LinkedDictionary <string, int>(7);

            for (int i = 0; i < 4; i++)
            {
                dictionary.Add(i.ToString(), 0);
            }
            var s_64bit = new string[] { "95e85f8e-67a3-4367-974f-dd24d8bb2ca2", "eb3d6fe9-de64-43a9-8f58-bddea727b1ca" };
            var s_32bit = new string[] { "25b1f130-7517-48e3-96b0-9da44e8bfe0e", "ba5a3625-bc38-4bf1-a707-a3cfe2158bae" };

            string[] chained = (Environment.Is64BitProcess ? s_64bit : s_32bit).ToArray();
            dictionary.Add(chained[0], 0);
            dictionary.Add(chained[1], 0);
            for (int i = 0; i < 4; i++)
            {
                dictionary.Remove(i.ToString());
            }
            dictionary.TrimExcess(3);
            Assert.Equal(2, dictionary.Count);
            int val;

            Assert.True(dictionary.TryGetValue(chained[0], out val));
            Assert.True(dictionary.TryGetValue(chained[1], out val));
        }
Ejemplo n.º 2
0
        ///<summary>Возвращает итератор, перечисляющий элементы индексатора
        ///IndexEntry</summary>
        public IEnumerator <Leaf> GetEnumerator()
        {
            CSharpDataStructures.Structures.Lists.LinkedList <Leaf> E =
                new CSharpDataStructures.Structures.Lists.LinkedList <Leaf>();
            STACK S = new STACK();

            S.Push(_tree);
            while (!S.IsEmpty())
            {
                Object b = S.Top();
                S.Pop();
                LinkedDictionary <Char, Object> children = (LinkedDictionary <Char, Object>)b;

                ICollection <Char> keys = children.Keys;
                foreach (Char k in keys)
                {
                    if (k == '$')
                    {
                        continue;
                    }
                    S.Push(children.GetValue(k));
                }
                if (children.ContainsKey('$') && children.GetValue('$') != null)
                {
                    E.add((Leaf)children.GetValue('$'));
                }
            }
            return(E.GetEnumerator());
        }
        public void TrimExcess_Generic_LargeInitialCapacity_TrimReducesSize()
        {
            var dictionary = new LinkedDictionary <TKey, TValue>(20);

            dictionary.TrimExcess(7);
            Assert.Equal(7, dictionary.EnsureCapacity(0));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Performs OCR with set parameters using provided
        /// <see cref="IOcrEngine"/>
        /// and
        /// creates PDF using provided
        /// <see cref="iText.Kernel.Pdf.PdfWriter"/>
        /// and
        /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/>.
        /// </summary>
        /// <remarks>
        /// Performs OCR with set parameters using provided
        /// <see cref="IOcrEngine"/>
        /// and
        /// creates PDF using provided
        /// <see cref="iText.Kernel.Pdf.PdfWriter"/>
        /// and
        /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/>.
        /// PDF/A-3u document will be created if
        /// provided
        /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/>
        /// is not null.
        /// </remarks>
        /// <param name="inputImages">
        ///
        /// <see cref="System.Collections.IList{E}"/>
        /// of images to be OCRed
        /// </param>
        /// <param name="pdfWriter">
        /// the
        /// <see cref="iText.Kernel.Pdf.PdfWriter"/>
        /// object
        /// to write final PDF document to
        /// </param>
        /// <param name="pdfOutputIntent">
        ///
        /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/>
        /// for PDF/A-3u document
        /// </param>
        /// <returns>
        /// result PDF/A-3u
        /// <see cref="iText.Kernel.Pdf.PdfDocument"/>
        /// object
        /// </returns>
        public PdfDocument CreatePdfA(IList <FileInfo> inputImages, PdfWriter pdfWriter, PdfOutputIntent pdfOutputIntent
                                      )
        {
            LOGGER.Info(MessageFormatUtil.Format(PdfOcrLogMessageConstant.START_OCR_FOR_IMAGES, inputImages.Count));
            IMetaInfo storedMetaInfo = null;

            if (ocrEngine is IThreadLocalMetaInfoAware)
            {
                storedMetaInfo = ((IThreadLocalMetaInfoAware)ocrEngine).GetThreadLocalMetaInfo();
                ((IThreadLocalMetaInfoAware)ocrEngine).SetThreadLocalMetaInfo(new OcrPdfCreatorMetaInfo(((IThreadLocalMetaInfoAware
                                                                                                          )ocrEngine).GetThreadLocalMetaInfo(), Guid.NewGuid(), null != pdfOutputIntent ? OcrPdfCreatorMetaInfo.PdfDocumentType
                                                                                                        .PDFA : OcrPdfCreatorMetaInfo.PdfDocumentType.PDF));
            }
            // map contains:
            // keys: image files
            // values:
            // map pageNumber -> retrieved text data(text and its coordinates)
            IDictionary <FileInfo, IDictionary <int, IList <TextInfo> > > imagesTextData = new LinkedDictionary <FileInfo, IDictionary
                                                                                                                 <int, IList <TextInfo> > >();

            try {
                foreach (FileInfo inputImage in inputImages)
                {
                    imagesTextData.Put(inputImage, ocrEngine.DoImageOcr(inputImage));
                }
            }
            finally {
                if (ocrEngine is IThreadLocalMetaInfoAware)
                {
                    ((IThreadLocalMetaInfoAware)ocrEngine).SetThreadLocalMetaInfo(storedMetaInfo);
                }
            }
            // create PdfDocument
            return(CreatePdfDocument(pdfWriter, pdfOutputIntent, imagesTextData));
        }
        public void TrimExcess_NoArgument_TrimAfterEachBulkAddOrRemove_TrimsToAtLeastCount(int initialCount, int numRemove, int numAdd, int newCount, int newCapacity)
        {
            Random random     = new Random(32);
            var    dictionary = new LinkedDictionary <int, int>();

            dictionary.TrimExcess();
            Assert.InRange(dictionary.EnsureCapacity(0), dictionary.Count, int.MaxValue);

            var initialKeys = new int[initialCount];

            for (int i = 0; i < initialCount; i++)
            {
                initialKeys[i] = i;
            }
            random.Shuffle(initialKeys);
            foreach (var key in initialKeys)
            {
                dictionary.Add(key, 0);
            }
            dictionary.TrimExcess();
            Assert.InRange(dictionary.EnsureCapacity(0), dictionary.Count, int.MaxValue);

            random.Shuffle(initialKeys);
            for (int i = 0; i < numRemove; i++)
            {
                dictionary.Remove(initialKeys[i]);
            }
            dictionary.TrimExcess();
            Assert.InRange(dictionary.EnsureCapacity(0), dictionary.Count, int.MaxValue);

            var moreKeys = new int[numAdd];

            for (int i = 0; i < numAdd; i++)
            {
                moreKeys[i] = i + initialCount;
            }
            random.Shuffle(moreKeys);
            foreach (var key in moreKeys)
            {
                dictionary.Add(key, 0);
            }
            int currentCount = dictionary.Count;

            dictionary.TrimExcess();
            Assert.InRange(dictionary.EnsureCapacity(0), currentCount, int.MaxValue);

            int[] existingKeys = new int[currentCount];
            Array.Copy(initialKeys, numRemove, existingKeys, 0, initialCount - numRemove);
            Array.Copy(moreKeys, 0, existingKeys, initialCount - numRemove, numAdd);
            random.Shuffle(existingKeys);
            for (int i = 0; i < currentCount - newCount; i++)
            {
                dictionary.Remove(existingKeys[i]);
            }
            dictionary.TrimExcess();
            int finalCapacity = dictionary.EnsureCapacity(0);

            Assert.InRange(finalCapacity, newCount, initialCount);
            Assert.Equal(newCapacity, finalCapacity);
        }
Ejemplo n.º 6
0
        private IDictionary <int, int[]> ReadFormat12()
        {
            IDictionary <int, int[]> h = new LinkedDictionary <int, int[]>();

            raf.SkipBytes(2);
            int table_length = raf.ReadInt();

            raf.SkipBytes(4);
            int nGroups = raf.ReadInt();

            for (int k = 0; k < nGroups; k++)
            {
                int startCharCode = raf.ReadInt();
                int endCharCode   = raf.ReadInt();
                int startGlyphID  = raf.ReadInt();
                for (int i = startCharCode; i <= endCharCode; i++)
                {
                    int[] r = new int[2];
                    r[0] = startGlyphID;
                    r[1] = GetGlyphWidth(r[0]);
                    h.Put(i, r);
                    startGlyphID++;
                }
            }
            return(h);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Linked dictionary:");

            var dictionary = new LinkedDictionary <int, string>();

            dictionary.Add(1, "One");
            dictionary.Add(2, "Two");
            dictionary.Add(3, "Three");
            dictionary.Add(101, "One hundred one");

            foreach (var item in dictionary)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nRemove 1, 101, 5: ");
            dictionary.Remove(1);
            dictionary.Remove(101);
            dictionary.Remove(5);

            foreach (var item in dictionary)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine($"\nSearch 2: {dictionary.Search(2)}");
        }
Ejemplo n.º 8
0
        internal virtual void AddNumericUpdate(NumericDocValuesUpdate update, int docIDUpto) // LUCENENET specific - Made internal rather than public, since this class is intended to be internal but couldn't be because it is exposed through a public API
        {
            if (!numericUpdates.TryGetValue(update.field, out LinkedDictionary <Term, NumericDocValuesUpdate> fieldUpdates))
            {
                fieldUpdates = new LinkedDictionary <Term, NumericDocValuesUpdate>();
                numericUpdates[update.field] = fieldUpdates;
                bytesUsed.AddAndGet(BYTES_PER_NUMERIC_FIELD_ENTRY);
            }

            if (fieldUpdates.TryGetValue(update.term, out NumericDocValuesUpdate current) && current != null && docIDUpto < current.docIDUpto)
            {
                // Only record the new number if it's greater than or equal to the current
                // one. this is important because if multiple threads are replacing the
                // same doc at nearly the same time, it's possible that one thread that
                // got a higher docID is scheduled before the other threads.
                return;
            }

            update.docIDUpto = docIDUpto;
            // since it's an LinkedHashMap, we must first remove the Term entry so that
            // it's added last (we're interested in insertion-order).
            if (current != null)
            {
                fieldUpdates.Remove(update.term);
            }
            fieldUpdates[update.term] = update;
            numNumericUpdates.IncrementAndGet();
            if (current is null)
            {
                bytesUsed.AddAndGet(BYTES_PER_NUMERIC_UPDATE_ENTRY + update.GetSizeInBytes());
            }
        }
Ejemplo n.º 9
0
        public static void TestRemove()
        {
            LinkedDictionary <string, int> linked = new LinkedDictionary <string, int>();

            linked.Add("a", 1);
            linked.Add("b", 2);
            Assert.AreEqual(linked.Count, 2);
            Assert.AreEqual(linked["a"], 1);
            Assert.AreEqual(linked["b"], 2);
            Assert.IsTrue(linked.ContainsKey("a"));
            Assert.IsTrue(linked.ContainsKey("b"));

            Assert.IsTrue(linked.Remove("a"));
            Assert.IsFalse(linked.Remove("c"));

            Assert.AreEqual(linked.Count, 1);
            Assert.IsFalse(linked.ContainsKey("a"));
            Assert.IsTrue(linked.ContainsKey("b"));
            Assert.AreEqual(linked["b"], 2);

            Assert.IsFalse(linked.Remove("a"));
            Assert.IsTrue(linked.Remove("b"));
            Assert.AreEqual(linked.Count, 0);
            Assert.IsFalse(linked.ContainsKey("b"));
        }
Ejemplo n.º 10
0
 internal Enumerator(LinkedDictionary <TKey, TValue> dictionary)
 {
     this.dictionary = dictionary;
     version         = dictionary.version;
     index           = -2;
     currentValue    = default(TValue);
 }
Ejemplo n.º 11
0
        public virtual void AddBinaryUpdate(BinaryDocValuesUpdate update, int docIDUpto)
        {
            if (!binaryUpdates.TryGetValue(update.field, out LinkedDictionary <Term, BinaryDocValuesUpdate> fieldUpdates))
            {
                fieldUpdates = new LinkedDictionary <Term, BinaryDocValuesUpdate>();
                binaryUpdates[update.field] = fieldUpdates;
                bytesUsed.AddAndGet(BYTES_PER_BINARY_FIELD_ENTRY);
            }

            if (fieldUpdates.TryGetValue(update.term, out BinaryDocValuesUpdate current) && current != null && docIDUpto < current.docIDUpto)
            {
                // Only record the new number if it's greater than or equal to the current
                // one. this is important because if multiple threads are replacing the
                // same doc at nearly the same time, it's possible that one thread that
                // got a higher docID is scheduled before the other threads.
                return;
            }

            update.docIDUpto = docIDUpto;
            // since it's an LinkedHashMap, we must first remove the Term entry so that
            // it's added last (we're interested in insertion-order).
            if (current != null)
            {
                fieldUpdates.Remove(update.term);
            }
            fieldUpdates[update.term] = update;
            numBinaryUpdates.IncrementAndGet();
            if (current == null)
            {
                bytesUsed.AddAndGet(BYTES_PER_BINARY_UPDATE_ENTRY + update.GetSizeInBytes());
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Parses each hocr file from the provided list, retrieves text, and
        /// returns data in the format described below.
        /// </summary>
        /// <param name="inputFiles">list of input files</param>
        /// <param name="textPositioning">
        ///
        /// <see cref="TextPositioning"/>
        /// </param>
        /// <returns>
        ///
        /// <see cref="System.Collections.IDictionary{K, V}"/>
        /// where key is
        /// <see cref="int?"/>
        /// representing the number of the page and value is
        /// <see cref="System.Collections.IList{E}"/>
        /// of
        /// <see cref="iText.Pdfocr.TextInfo"/>
        /// elements where each
        /// <see cref="iText.Pdfocr.TextInfo"/>
        /// element contains a word or a line and its 4
        /// coordinates(bbox)
        /// </returns>
        public static IDictionary <int, IList <TextInfo> > ParseHocrFile(IList <FileInfo> inputFiles, TextPositioning
                                                                         textPositioning)
        {
            IDictionary <int, IList <TextInfo> > imageData = new LinkedDictionary <int, IList <TextInfo> >();
            IDictionary <String, iText.StyledXmlParser.Jsoup.Nodes.Node> unparsedBBoxes = new LinkedDictionary <String,
                                                                                                                iText.StyledXmlParser.Jsoup.Nodes.Node>();

            foreach (FileInfo inputFile in inputFiles)
            {
                if (inputFile != null && File.Exists(System.IO.Path.Combine(inputFile.FullName)))
                {
                    FileStream fileInputStream = new FileStream(inputFile.FullName, FileMode.Open, FileAccess.Read);
                    Document   doc             = iText.StyledXmlParser.Jsoup.Jsoup.Parse(fileInputStream, System.Text.Encoding.UTF8.Name(),
                                                                                         inputFile.FullName);
                    Elements       pages           = doc.GetElementsByClass("ocr_page");
                    IList <String> searchedClasses = TextPositioning.BY_LINES.Equals(textPositioning) ? JavaUtil.ArraysAsList("ocr_line"
                                                                                                                              , "ocr_caption") : JavaCollectionsUtil.SingletonList <String>("ocrx_word");
                    foreach (iText.StyledXmlParser.Jsoup.Nodes.Element page in pages)
                    {
                        String[] pageNum    = iText.IO.Util.StringUtil.Split(page.Id(), "page_");
                        int      pageNumber = Convert.ToInt32(pageNum[pageNum.Length - 1], System.Globalization.CultureInfo.InvariantCulture
                                                              );
                        IList <TextInfo> textData = new List <TextInfo>();
                        if (searchedClasses.Count > 0)
                        {
                            Elements objects = page.GetElementsByClass(searchedClasses[0]);
                            for (int i = 1; i < searchedClasses.Count; i++)
                            {
                                Elements foundElements = page.GetElementsByClass(searchedClasses[i]);
                                for (int j = 0; j < foundElements.Count; j++)
                                {
                                    objects.Add(foundElements[j]);
                                }
                            }
                            foreach (iText.StyledXmlParser.Jsoup.Nodes.Element obj in objects)
                            {
                                IList <float> coordinates = GetAlignedBBox(obj, textPositioning, unparsedBBoxes);
                                textData.Add(new TextInfo(obj.Text(), coordinates));
                            }
                        }
                        if (textData.Count > 0)
                        {
                            if (imageData.ContainsKey(pageNumber))
                            {
                                pageNumber = Enumerable.Max(imageData.Keys) + 1;
                            }
                            imageData.Put(pageNumber, textData);
                        }
                    }
                    fileInputStream.Dispose();
                }
            }
            foreach (iText.StyledXmlParser.Jsoup.Nodes.Node node in unparsedBBoxes.Values)
            {
                LOGGER.Warn(MessageFormatUtil.Format(Tesseract4LogMessageConstant.CANNOT_PARSE_NODE_BBOX, node.ToString())
                            );
            }
            return(imageData);
        }
Ejemplo n.º 13
0
        public void CopyConstructor_MutateOriginal_CopyIsUnaffected()
        {
            var linkedDictionary = InitializeDictionarySequentialKeys(30);
            var copyDictionary   = new LinkedDictionary <int, int>(linkedDictionary);

            linkedDictionary.Remove(15);
            Assert.True(copyDictionary.ContainsKey(15));
        }
Ejemplo n.º 14
0
 public ValueCollection(LinkedDictionary <TKey, TValue> dictionary)
 {
     if (dictionary == null)
     {
         ThrowHelper.ThrowArgumentNullException(ThrowHelper.dictionary);
     }
     this.dictionary = dictionary;
 }
Ejemplo n.º 15
0
 public _Dataset(Attributes enclosing)
 {
     if (enclosing.attributes == null)
     {
         enclosing.attributes = new LinkedDictionary <string, Attribute>(2);
     }
     this.enclosingAttributes = enclosing.attributes;
 }
Ejemplo n.º 16
0
 internal Enumerator(LinkedDictionary <TKey, TValue> dictionary, int getEnumeratorRetType)
 {
     this.dictionary           = dictionary;
     version                   = dictionary.version;
     index                     = -2;
     this.getEnumeratorRetType = getEnumeratorRetType;
     current                   = new KeyValuePair <TKey, TValue>();
 }
        public void CantAcceptDuplicateKeysFromSourceDictionary()
        {
            LinkedDictionary <string, int> source = new LinkedDictionary <string, int> {
                { "a", 1 }, { "A", 1 }
            };

            AssertExtensions.Throws <ArgumentException>(null, () => new LinkedDictionary <string, int>(source, StringComparer.OrdinalIgnoreCase));
        }
 public void IDictionary_NonGeneric_Contains_KeyOfWrongType()
 {
     if (!IsReadOnly)
     {
         IDictionary dictionary = new LinkedDictionary <string, int>();
         Assert.False(dictionary.Contains(1));
     }
 }
Ejemplo n.º 19
0
        public AssetLoadTask()
        {
            m_LoadedCallbackList   = new LinkedDictionary <AssetAsyncLoad, UnityAction <Object> >();
            m_ProgressCallbackList = new LinkedDictionary <AssetAsyncLoad, UnityAction <float> >();

            m_LoadedCallbackList.ReverseEnumerate   = true;
            m_ProgressCallbackList.ReverseEnumerate = true;
        }
        public void LinkedDictionary_Generic_Constructor_int_IEqualityComparer(int count)
        {
            SCG.IEqualityComparer <TKey>    comparer   = GetKeyIEqualityComparer();
            LinkedDictionary <TKey, TValue> dictionary = new LinkedDictionary <TKey, TValue>(count, comparer);

            Assert.Equal(0, dictionary.Count);
            Assert.Equal(comparer, dictionary.EqualityComparer);
        }
        public void TrimExcess_Generic_DictionaryNotInitialized_CapacityRemainsAsMinPossible()
        {
            var dictionary = new LinkedDictionary <TKey, TValue>();

            Assert.Equal(0, dictionary.EnsureCapacity(0));
            dictionary.TrimExcess();
            Assert.Equal(0, dictionary.EnsureCapacity(0));
        }
Ejemplo n.º 22
0
 /// <summary>Set a new attribute, or replace an existing one by key.</summary>
 /// <param name="attribute">attribute</param>
 public virtual void Put(iText.StyledXmlParser.Jsoup.Nodes.Attribute attribute)
 {
     Validate.NotNull(attribute);
     if (attributes == null)
     {
         attributes = new LinkedDictionary <String, iText.StyledXmlParser.Jsoup.Nodes.Attribute>(2);
     }
     attributes[attribute.Key] = attribute;
 }
        public void LinkedDictionary_Generic_Constructor_IEqualityComparer(int count)
        {
            SCG.IEqualityComparer <TKey>    comparer = GetKeyIEqualityComparer();
            SCG.IDictionary <TKey, TValue>  source   = GenericIDictionaryFactory(count);
            LinkedDictionary <TKey, TValue> copied   = new LinkedDictionary <TKey, TValue>(source, comparer);

            Assert.Equal(source, copied);
            Assert.Equal(comparer, copied.EqualityComparer);
        }
        public void TrimExcess_Generic_DoesInvalidateEnumeration()
        {
            var dictionary = new LinkedDictionary <TKey, TValue>(20);
            var enumerator = dictionary.GetEnumerator();

            dictionary.TrimExcess(7); // Verify TrimExcess does invalidate enumeration

            Assert.Throws <InvalidOperationException>(() => enumerator.MoveNext());
        }
        public void EnsureCapacity_Generic_ExistingCapacityRequested_SameValueReturned(int capacity)
        {
            var dictionary = new LinkedDictionary <TKey, TValue>(capacity);

            Assert.Equal(capacity, dictionary.EnsureCapacity(capacity));

            dictionary = (LinkedDictionary <TKey, TValue>)GenericIDictionaryFactory(capacity);
            Assert.Equal(capacity, dictionary.EnsureCapacity(capacity));
        }
 public void IDictionary_NonGeneric_ItemSet_KeyOfWrongType()
 {
     if (!IsReadOnly)
     {
         IDictionary dictionary = new LinkedDictionary <string, string>();
         AssertExtensions.Throws <ArgumentException>("key", () => dictionary[23] = CreateTValue(12345));
         Assert.Empty(dictionary);
     }
 }
Ejemplo n.º 27
0
        public static void CallSaveMessages(int clientId, LinkedDictionary <DateTime, string> messages)
        {
            var data = new List <MessageData>(messages.ConvertAll <KeyValuePair <DateTime, string>, MessageData>(i => new MessageData {
                Date = i.Key, Message = i.Value
            }));

            using (var client = new DataServiceClient())
                client.SaveMessages(data.ToArray(), clientId);
        }
        private static IDictionary <T, T> CreateDictionary <T>(int size, Func <int, T> keyValueSelector, IEqualityComparer <T> comparer = null)
        {
            SCG.Dictionary <T, T>   temp = Enumerable.Range(0, size + 1).ToDictionary(keyValueSelector, keyValueSelector, comparer);
            LinkedDictionary <T, T> dict = new LinkedDictionary <T, T>(temp, comparer);

            // Remove first item to reduce Count to size and alter the contiguity of the dictionary
            dict.Remove(keyValueSelector(0));
            return(dict);
        }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            LinkedDictionary <String, ICommand> cmds    = new LinkedDictionary <String, ICommand>();
            IHandler <String, String[]>         handler = new StringHandler();

            CurrentDirectory dir = new CurrentDirectory()
            {
                CPath = System.IO.Directory.GetCurrentDirectory()
            };

            cmds.Add("change", new ChangeCommand(dir));
            cmds.Add("mkfile", new MkFileCommand(dir));
            cmds.Add("show", new ShowCommand(dir));
            cmds.Add("mkdir", new MkDirCommand(dir));
            cmds.Add("copy", new CopyCommand(dir));
            cmds.Add("s", new ShowCommand(dir));
            cmds.Add("help", new HelpCommand(GetCmds(cmds.Values)));


            Console.WriteLine("===Welcome to the ConsoleCommander===\nTo see available commands type help\n");
            while (true)
            {
                String c = Console.ReadLine();

                String[] A   = handler.Handle(c);//c.Split(new Char[]{'-',' ','='},StringSplitOptions.RemoveEmptyEntries);
                ICommand cmd = cmds[A[0]];
                if (A[0] == "change")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "mkfile")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "mkdir")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "show" || A[0] == "s")
                {
                    cmd.Execute(null);
                }
                else if (A[0] == "copy")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else if (A[0] == "help")
                {
                    cmd.Execute(GetArgs <String>(A));
                }
                else
                {
                    break;
                }
            }
        }
        public void TrimExcess_Generic_ClearThenTrimNonEmptyDictionary_SetsCapacityTo3(int count)
        {
            LinkedDictionary <TKey, TValue> dictionary = (LinkedDictionary <TKey, TValue>)GenericIDictionaryFactory(count);

            Assert.Equal(count, dictionary.Count);
            // The smallest possible capacity size after clearing a dictionary is 3
            dictionary.Clear();
            dictionary.TrimExcess();
            Assert.Equal(3, dictionary.EnsureCapacity(0));
        }
 public EndpointState(BitcoinEndpoint endpoint)
 {
     Endpoint = endpoint;
     AdvertisedBlocks = new LinkedDictionary<byte[], DateTime>(ByteArrayComparer.Instance);
     BlockRequests = new Dictionary<byte[], BlockRequest>(ByteArrayComparer.Instance);
 }