Exemple #1
0
        public bool Load(byte[] ProjectData)
        {
            string currentConfig = "Default";
            string activeElement = "";

            Node     = new System.Windows.Forms.TreeNode();
            Node.Tag = this;
            Node.Collapse();

            GR.IO.MemoryReader memIn = new GR.IO.MemoryReader(ProjectData);

            GR.IO.FileChunk chunk = new GR.IO.FileChunk();
            ushort          origDebugStartAddress = 0;

            while (chunk.ReadFromStream(memIn))
            {
                GR.IO.MemoryReader memChunk = chunk.MemoryReader();
                switch (chunk.Type)
                {
                case Types.FileChunk.PROJECT:
                    // Project Info

                    // Version
                    uint projectVersion = memChunk.ReadUInt32();
                    Settings.Name         = memChunk.ReadString();
                    Settings.Filename     = memChunk.ReadString();
                    Settings.DebugPort    = memChunk.ReadUInt16();
                    origDebugStartAddress = memChunk.ReadUInt16();
                    Settings.BuildTool    = memChunk.ReadString();
                    Settings.RunTool      = memChunk.ReadString();
                    Settings.MainDocument = memChunk.ReadString();
                    currentConfig         = memChunk.ReadString();
                    activeElement         = memChunk.ReadString();
                    memChunk.ReadUInt32(); // flags (all free)

                    if (projectVersion == 1)
                    {
                        if (origDebugStartAddress == 2049)
                        {
                            origDebugStartAddress = 0;
                        }
                    }

                    Node.Text = Settings.Name;
                    break;

                case Types.FileChunk.PROJECT_ELEMENT:
                    // Element Info
                {
                    // Version
                    int elementVersion = (int)memChunk.ReadUInt32();

                    ProjectElement.ElementType type = (ProjectElement.ElementType)memChunk.ReadUInt32();

                    //System.Windows.Forms.TreeNode nodeParent = NodeFromHierarchy(

                    ProjectElement element = CreateElement(type, Node);
                    element.Name = memChunk.ReadString();
                    //element.Filename = System.IO.Path.GetFileName( memChunk.ReadString() );
                    element.Filename = memChunk.ReadString();
                    if (element.DocumentInfo.Type == ProjectElement.ElementType.FOLDER)
                    {
                        element.Node.Text = element.Name;
                    }
                    else
                    {
                        element.Node.Text = System.IO.Path.GetFileName(element.Filename);
                    }
                    if (Core.Navigating.Solution.IsNodeExpanded(element))
                    {
                        element.Node.Expand();
                    }
                    else
                    {
                        element.Node.Collapse();
                    }

                    GR.IO.FileChunk subChunk = new GR.IO.FileChunk();

                    if (!subChunk.ReadFromStream(memChunk))
                    {
                        return(false);
                    }
                    if (subChunk.Type != Types.FileChunk.PROJECT_ELEMENT_DATA)
                    {
                        return(false);
                    }
                    // Element Data
                    element.DocumentInfo.DocumentFilename = element.Filename;
                    if (element.Document != null)
                    {
                        if (!element.Document.ReadFromReader(subChunk.MemoryReader()))
                        {
                            Elements.Remove(element);
                            element.Document.Dispose();
                            element = null;
                        }
                        else
                        {
                            element.Document.SetDocumentFilename(element.Filename);
                        }
                    }
                    element.TargetFilename = memChunk.ReadString();
                    element.TargetType     = (Types.CompileTargetType)memChunk.ReadUInt32();
                    int dependencyCount = memChunk.ReadInt32();
                    for (int i = 0; i < dependencyCount; ++i)
                    {
                        string dependency = memChunk.ReadString();
                        element.ForcedDependency.DependentOnFile.Add(new FileDependency.DependencyInfo(Settings.Name, dependency, true, false));
                    }
                    element.StartAddress = memChunk.ReadString();
                    // 2 free strings
                    memChunk.ReadString();
                    memChunk.ReadString();

                    int perConfigSettingCount = memChunk.ReadInt32();
                    for (int i = 0; i < perConfigSettingCount; ++i)
                    {
                        GR.IO.FileChunk chunkElementPerConfigSetting = new GR.IO.FileChunk();
                        chunkElementPerConfigSetting.ReadFromStream(memChunk);
                        if (chunkElementPerConfigSetting.Type == Types.FileChunk.PROJECT_ELEMENT_PER_CONFIG_SETTING)
                        {
                            ProjectElement.PerConfigSettings perConfigSetting = new ProjectElement.PerConfigSettings();
                            GR.IO.MemoryReader memSubChunk = chunkElementPerConfigSetting.MemoryReader();
                            string             config      = memSubChunk.ReadString();

                            perConfigSetting.PreBuild      = memSubChunk.ReadString();
                            perConfigSetting.CustomBuild   = memSubChunk.ReadString();
                            perConfigSetting.PostBuild     = memSubChunk.ReadString();
                            perConfigSetting.DebugFile     = memSubChunk.ReadString();
                            perConfigSetting.DebugFileType = (C64Studio.Types.CompileTargetType)memSubChunk.ReadInt32();

                            perConfigSetting.PreBuildChain.Active = (memSubChunk.ReadInt32() == 1);
                            int numEntries = memSubChunk.ReadInt32();
                            for (int j = 0; j < numEntries; ++j)
                            {
                                var entry = new BuildChainEntry();

                                entry.ProjectName      = memSubChunk.ReadString();
                                entry.Config           = memSubChunk.ReadString();
                                entry.DocumentFilename = memSubChunk.ReadString();
                                entry.PreDefines       = memSubChunk.ReadString();

                                perConfigSetting.PreBuildChain.Entries.Add(entry);
                            }

                            perConfigSetting.PostBuildChain.Active = (memSubChunk.ReadInt32() == 1);
                            numEntries = memSubChunk.ReadInt32();
                            for (int j = 0; j < numEntries; ++j)
                            {
                                var entry = new BuildChainEntry();

                                entry.ProjectName      = memSubChunk.ReadString();
                                entry.Config           = memSubChunk.ReadString();
                                entry.DocumentFilename = memSubChunk.ReadString();
                                entry.PreDefines       = memSubChunk.ReadString();

                                perConfigSetting.PostBuildChain.Entries.Add(entry);
                            }
                            element.Settings[config] = perConfigSetting;
                        }
                    }

                    uint flags = memChunk.ReadUInt32();
                    element.IsShown       = ((flags & 1) != 0);
                    element.AssemblerType = (C64Studio.Types.AssemblerType)memChunk.ReadUInt32();

                    int hierarchyPartCount = memChunk.ReadInt32();
                    for (int i = 0; i < hierarchyPartCount; ++i)
                    {
                        string part = memChunk.ReadString();

                        element.ProjectHierarchy.Add(part);
                    }

                    if (element.ProjectHierarchy.Count > 0)
                    {
                        // node is sub-node, move accordingly
                        System.Windows.Forms.TreeNode parentNode = NodeFromHierarchy(element.ProjectHierarchy);
                        if ((parentNode != null) &&
                            (parentNode != element.Node.Parent))
                        {
                            element.Node.Remove();
                            parentNode.Nodes.Add(element.Node);
                        }
                    }

                    // dependency - include symbols
                    dependencyCount = memChunk.ReadInt32();
                    for (int i = 0; i < dependencyCount; ++i)
                    {
                        element.ForcedDependency.DependentOnFile[i].IncludeSymbols = (memChunk.ReadInt32() != 0);
                    }

                    // code folding entries
                    int numFoldingEntries = memChunk.ReadInt32();
                    element.DocumentInfo.CollapsedFoldingBlocks = new GR.Collections.Set <int>();
                    for (int i = 0; i < numFoldingEntries; ++i)
                    {
                        int collapsedBlockLine = memChunk.ReadInt32();
                        element.DocumentInfo.CollapsedFoldingBlocks.Add(collapsedBlockLine);
                        //Debug.Log( "Get collapsed blocked for " + element.DocumentInfo.FullPath + ", line " + collapsedBlockLine );
                    }

                    // external dependencies
                    int externalDependencyCount = memChunk.ReadInt32();
                    for (int i = 0; i < externalDependencyCount; ++i)
                    {
                        string dependency = memChunk.ReadString();
                        element.ExternalDependencies.DependentOnFile.Add(new FileDependency.DependencyInfo("", dependency, true, false));
                    }

                    var obsoleteBasicVersion = (BasicVersion)memChunk.ReadUInt32();

                    // dependency - project
                    dependencyCount = memChunk.ReadInt32();
                    for (int i = 0; i < dependencyCount; ++i)
                    {
                        element.ForcedDependency.DependentOnFile[i].Project = memChunk.ReadString();
                    }

                    element.BASICDialect = memChunk.ReadString();
                    if (string.IsNullOrEmpty(element.BASICDialect))
                    {
                        // old version, find dialect from obsoleteBasicVersion
                        string dialectKey = "BASIC V2";
                        switch (obsoleteBasicVersion)
                        {
                        case BasicVersion.C64_BASIC_V2:
                            break;

                        case BasicVersion.BASIC_LIGHTNING:
                            dialectKey = "BASIC Lightning";
                            break;

                        case BasicVersion.LASER_BASIC:
                            dialectKey = "Laser BASIC";
                            break;

                        case BasicVersion.SIMONS_BASIC:
                            dialectKey = "Simon's BASIC";
                            break;

                        case BasicVersion.V3_5:
                            dialectKey = "BASIC V3.5";
                            break;

                        case BasicVersion.V7_0:
                            dialectKey = "BASIC V7.0";
                            break;
                        }
                        if (Core.Compiling.BASICDialects.ContainsKey(dialectKey))
                        {
                            element.BASICDialect = dialectKey;
                        }
                    }

                    // TODO - load other stuff
                    if ((element != null) &&
                        (element.IsShown))
                    {
                        ShowDocument(element);
                        if (element.Document != null)
                        {
                            element.Document.ShowHint = DockState.Document;
                            //element.Document.Show( MainForm.panelMain );
                        }
                    }
                }
                break;

                case Types.FileChunk.PROJECT_ELEMENT_DISPLAY_DATA:
                {
                    string elementFilename = memChunk.ReadString();

                    ProjectElement element = GetElementByFilename(elementFilename);
                    if (element != null)
                    {
                        UInt32 numBytes = memChunk.ReadUInt32();
                        GR.Memory.ByteBuffer displayData = new GR.Memory.ByteBuffer();
                        memChunk.ReadBlock(displayData, numBytes);

                        if (element.Document != null)
                        {
                            element.Document.ApplyDisplayDetails(displayData);
                        }
                    }
                }
                break;

                case Types.FileChunk.PROJECT_CONFIG:
                {
                    ProjectConfig config = new ProjectConfig();

                    config.Load(memChunk);

                    if (string.IsNullOrEmpty(config.DebugStartAddressLabel))
                    {
                        config.DebugStartAddressLabel = origDebugStartAddress.ToString();
                    }

                    Settings.Configuration(config.Name, config);
                }
                break;

                case Types.FileChunk.PROJECT_WATCH_ENTRY:
                {
                    WatchEntry watch = new WatchEntry();

                    watch.Load(memChunk);
                    //Core.MainForm.AddWatchEntry( watch );
                    Settings.WatchEntries.Add(watch);
                    //Debug.Log( "loaded watch entry for " + watch.Name );
                }
                break;
                }
            }
            if (Settings.GetConfigurationCount() == 0)
            {
                // there must be one config
                ProjectConfig config = new ProjectConfig();

                config.Name = "Default";
                Settings.Configuration(config.Name, config);
                Settings.CurrentConfig = config;
            }
            else
            {
                Settings.CurrentConfig = Settings.Configuration(currentConfig);
                if (Settings.CurrentConfig == null)
                {
                    Settings.CurrentConfig = Settings.GetConfigurations().First();
                }
            }
            foreach (ProjectElement element in Elements)
            {
                if (element.Settings.Count == 0)
                {
                    foreach (var configName in Settings.GetConfigurationNames())
                    {
                        // needs a default setting!
                        element.Settings[configName] = new ProjectElement.PerConfigSettings();
                    }
                }
                if ((!string.IsNullOrEmpty(element.Filename)) &&
                    (GR.Path.IsPathEqual(element.Filename, Settings.MainDocument)))
                {
                    Core.MainForm.m_SolutionExplorer.HighlightNode(element.Node);
                }

                Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.DOCUMENT_INFO_CREATED, element.DocumentInfo));
                Core.MainForm.RaiseApplicationEvent(new C64Studio.Types.ApplicationEvent(C64Studio.Types.ApplicationEvent.Type.ELEMENT_CREATED, element));
            }



            if (!String.IsNullOrEmpty(activeElement))
            {
                ProjectElement element = GetElementByFilename(activeElement);
                if ((element != null) &&
                    (element.Document != null))
                {
                    element.Document.Show();
                }
            }
            m_Modified = false;
            return(true);
        }
 public bool Remove(T value) => linkedList.Remove(value);
Exemple #3
0
        public bool Load(string Filename)
        {
            byte[] projectData = null;
            try
            {
                projectData = System.IO.File.ReadAllBytes(Filename);
            }
            catch (System.IO.IOException)
            {
                return(false);
            }

            Settings.Filename = Filename;
            Settings.BasePath = System.IO.Path.GetDirectoryName(Settings.Filename);

            GR.IO.MemoryReader memIn = new GR.IO.MemoryReader(projectData);

            GR.IO.FileChunk chunk = new GR.IO.FileChunk();

            while (chunk.ReadFromStream(memIn))
            {
                GR.IO.MemoryReader memChunk = chunk.MemoryReader();
                switch (chunk.Type)
                {
                case Types.FileChunk.PROJECT:
                    // Project Info

                    // Version
                    memChunk.ReadUInt32();
                    Settings.Name              = memChunk.ReadString();
                    Settings.Filename          = memChunk.ReadString();
                    Settings.DebugPort         = memChunk.ReadUInt16();
                    Settings.DebugStartAddress = memChunk.ReadUInt16();
                    Settings.BuildTool         = memChunk.ReadString();
                    Settings.RunTool           = memChunk.ReadString();
                    Settings.MainDocument      = memChunk.ReadString();
                    break;

                case Types.FileChunk.PROJECT_ELEMENT:
                    // Element Info
                {
                    // Version
                    int version = (int)memChunk.ReadUInt32();

                    ProjectElement.ElementType type = (ProjectElement.ElementType)memChunk.ReadUInt32();

                    ProjectElement element = CreateElement(type);
                    element.Name     = memChunk.ReadString();
                    element.Filename = memChunk.ReadString();
                    ShowDocument(element);

                    GR.IO.FileChunk subChunk = new GR.IO.FileChunk();

                    if (!subChunk.ReadFromStream(memChunk))
                    {
                        return(false);
                    }
                    if (subChunk.Type != Types.FileChunk.PROJECT_ELEMENT_DATA)
                    {
                        return(false);
                    }
                    // Element Data
                    if (element.Document != null)
                    {
                        if (!element.Document.ReadFromReader(subChunk.MemoryReader()))
                        {
                            Elements.Remove(element);
                            element.Document.Dispose();
                            element = null;
                        }
                    }
                    element.TargetFilename = memChunk.ReadString();
                    element.TargetType     = (FileParser.CompileTargetType)memChunk.ReadUInt32();

                    if ((element != null) &&
                        (element.Document != null))
                    {
                        element.Document.ShowHint = DockState.Document;
                        element.Document.Show(MainForm.panelMain);
                    }
                }
                break;
                }
            }
            Settings.Filename = Filename;
            m_Modified        = false;
            return(true);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            IncreaseCost[] applications = new IncreaseCost[4];
            IncreaseCost   app0         = new Game("Heroes3", 15, 200, "No license");
            IncreaseCost   app1         = new Game("Disciples", 5, 500, "Official license");
            IncreaseCost   app2         = new Software("Util_1", 0, 30);
            IncreaseCost   app3         = new Software("Util_1", 0, 40);

            applications[0] = app0;
            applications[1] = app1;
            applications[2] = app2;
            applications[3] = app3;

            list1.AddRange(applications);

            list2.AddFirst(app0);
            list2.AddAfter(list2.First, app1);
            list2.AddLast(app2);
            list2.AddAfter(list2.Last, app3);

            //list1.Add(new Game("Heroes3", 15, 200, "No license"));

            int flag = 100;

            while (flag != 0)
            {
                Console.Clear();
                Console.WriteLine("Меню : ");
                Console.WriteLine("1 – просмотр коллекции");
                Console.WriteLine("2 – добавление элемента (используйте конструктор с 1-2 параметрами)");
                Console.WriteLine("3 – добавление элемента по указанному индексу");
                Console.WriteLine("4 – нахождение элемента с начала коллекции (переопределить метод Equals или оператор == для вашего класса – сравнение только по полю name)");
                Console.WriteLine("5 – нахождение элемента с конца коллекции");
                Console.WriteLine("6 – удаление элемента по индексу");
                Console.WriteLine("7 – удаление элемента по значению");
                Console.WriteLine("8 – реверс коллекции");
                Console.WriteLine("9 – сортировка");
                Console.WriteLine("10 – выполнение методов всех объектов, поддерживающих Interface2");

                Console.WriteLine("11 – LinkedList просмотр коллекции");
                Console.WriteLine("12 – LinkedList добавление элемента (используйте конструктор с 1-2 параметрами)");
                Console.WriteLine("13 – LinkedList добавление элемента по указанному индексу");
                Console.WriteLine("14 – LinkedList нахождение элемента с начала коллекции (переопределить метод Equals или оператор == для вашего класса – сравнение только по полю name)");
                Console.WriteLine("15 – LinkedList нахождение элемента с конца коллекции");
                Console.WriteLine("16 – LinkedList удаление элемента по индексу");
                Console.WriteLine("17 – LinkedList удаление элемента по значению");
                Console.WriteLine("18 – LinkedList реверс коллекции");
                Console.WriteLine("19 – LinkedList сортировка");
                Console.WriteLine("20 – LinkedList выполнение методов всех объектов, поддерживающих Interface2");

                Console.WriteLine("0 – выход");
                flag = Convert.ToInt32(Console.ReadLine());

                switch (flag)
                {
                //просмотр коллекции
                case (1):
                {
                    Console.Clear();

                    if (Program.list1.Count > 0)
                    {
                        Console.WriteLine("list1 содержит : " + list1.Count);
                        foreach (Object obj in Program.list1)
                        {
                            Console.WriteLine("************************************************************");
                            Console.WriteLine(obj.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("list1 пустой");
                    }

                    Console.ReadLine();
                    break;
                }

                //добавление элемента
                case (2):
                {
                    Console.Clear();

                    Console.WriteLine("Теперь создаем обьект");
                    Console.WriteLine("Введите name");
                    String name = Console.ReadLine();
                    Console.WriteLine("Введите bugs");
                    int bugs = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Введите cost");
                    double cost = Convert.ToDouble(Console.ReadLine());
                    Console.WriteLine("Введите licenseAgreement");
                    String licenseAgreement = Console.ReadLine();

                    if (licenseAgreement.Equals("0"))
                    {
                        list1.Add(new Software(name, bugs, cost));
                        Console.WriteLine("Done");
                        Console.WriteLine("создали Software");
                    }
                    else
                    {
                        list1.Add(new Game(name, bugs, cost, licenseAgreement));
                        Console.WriteLine("Done");
                        Console.WriteLine("создали Game");
                    }
                    Console.WriteLine("И добавили в list1");

                    Console.ReadLine();
                    break;
                }

                //добавление элемента по указанному индексу
                case (3):
                {
                    Console.Clear();
                    try
                    {
                        Console.WriteLine("Теперь создаем обьект");
                        Console.WriteLine("Введите name");
                        String name = Console.ReadLine();
                        Console.WriteLine("Введите bugs");
                        int bugs = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("Введите cost");
                        double cost = Convert.ToDouble(Console.ReadLine());
                        Console.WriteLine("Введите licenseAgreement");
                        String licenseAgreement = Console.ReadLine();
                        Console.WriteLine("Введите index");
                        int index = Convert.ToInt32(Console.ReadLine());

                        if (licenseAgreement.Equals("0"))
                        {
                            list1.Insert(index, new Software(name, bugs, cost));
                            Console.WriteLine("Done");
                            Console.WriteLine("создали Software");
                        }
                        else
                        {
                            list1.Insert(index, new Game(name, bugs, cost, licenseAgreement));
                            Console.WriteLine("Done");
                            Console.WriteLine("создали Game");
                        }
                        Console.WriteLine("И добавили в list1");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Не могу выполнить");
                    }

                    Console.ReadLine();
                    break;
                }

                //нахождение элемента с начала коллекции
                case (4):
                {
                    Console.Clear();

                    Console.WriteLine("Находим элемент по имени name с начала");
                    Console.WriteLine("Введите name");
                    String   name    = Console.ReadLine();
                    Software finding = null;
                    for (int i = 0; i < list1.Count; i++)
                    {
                        if (name.Equals(((Software)list1[i]).getName()))
                        {
                            finding = (Software)list1[i];
                            break;
                        }
                    }

                    if (finding != null)
                    {
                        Console.WriteLine("Нашел");
                        if (finding is Game)
                        {
                            Console.WriteLine(((Game)finding).ToString());
                        }
                        else
                        {
                            Console.WriteLine(((Software)finding).ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("Не нашел");
                    }

                    Console.ReadLine();
                    break;
                }

                //нахождение элемента с конца коллекции
                case (5):
                {
                    Console.Clear();

                    Console.WriteLine("Находим элемент по имени name с конца");
                    Console.WriteLine("Введите name");
                    String   name    = Console.ReadLine();
                    Software finding = null;

                    for (int i = list1.Count - 1; i >= 0; i--)
                    {
                        if (name.Equals(((Software)list1[i]).getName()))
                        {
                            finding = (Software)list1[i];
                            break;
                        }
                    }

                    if (finding != null)
                    {
                        Console.WriteLine("Нашел");
                        if (finding is Game)
                        {
                            Console.WriteLine(((Game)finding).ToString());
                        }
                        else
                        {
                            Console.WriteLine(((Software)finding).ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("Не нашел");
                    }

                    Console.ReadLine();
                    break;
                }

                //удаление элемента по индексу
                case (6):
                {
                    Console.Clear();

                    try
                    {
                        Console.WriteLine("Удалим элемент по индексу");
                        Console.WriteLine("Введите индекс");
                        int index = Convert.ToInt32(Console.ReadLine());
                        list1.RemoveAt(index);
                        Console.WriteLine("Эх жаль элемента");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Че-то пошло не так :)");
                    }

                    Console.ReadLine();
                    break;
                }

                //удаление элемента по значению
                case (7):
                {
                    Console.Clear();

                    try
                    {
                        Console.WriteLine("Удалим элемент по значению");
                        Console.WriteLine("Введите name");
                        String name = Console.ReadLine();
                        for (int i = 0; i < list1.Count; i++)
                        {
                            if (name.Equals(((Software)list1[i]).getName()))
                            {
                                list1.RemoveAt(i);
                                Console.WriteLine("Эх жаль элемента");
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Че-то пошло не так :)");
                    }

                    Console.ReadLine();
                    break;
                }

                //реверс коллекции
                case (8):
                {
                    Console.Clear();

                    Console.WriteLine("Произведем реверс list1");
                    list1.Reverse();
                    Console.WriteLine("Готово :)");

                    Console.ReadLine();
                    break;
                }

                //сортировка
                case (9):
                {
                    Console.Clear();

                    Console.WriteLine("Отсортируем по name list1");
                    list1.Sort();
                    Console.WriteLine("Готово )");

                    Console.ReadLine();
                    break;
                }

                //выполнение методов всех объектов, поддерживающих Interface2
                case (10):
                {
                    Console.Clear();

                    foreach (IncreaseCost obj in list1)
                    {
                        if (obj is DecreaseCost)
                        {
                            Console.WriteLine("Ура");
                            Console.WriteLine("************************************************************");
                            ((DecreaseCost)obj).decreaseCost();
                            ((DecreaseCost)obj).information();
                            ((DecreaseCost)obj).statistic();
                            ((DecreaseCost)obj).info();
                        }
                    }


                    Console.ReadLine();
                    break;
                }


                //LinkedList просмотр коллекции
                case (11):
                {
                    Console.Clear();

                    if (Program.list2.Count > 0)
                    {
                        Console.WriteLine("list2 содержит : " + list2.Count);
                        foreach (Object obj in Program.list2)
                        {
                            Console.WriteLine("************************************************************");
                            Console.WriteLine(obj.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("list2 пустой");
                    }

                    Console.ReadLine();
                    break;
                }

                //LinkedList добавление элемента
                case (12):
                {
                    Console.Clear();

                    Console.WriteLine("Теперь создаем обьект");
                    Console.WriteLine("Введите name");
                    String name = Console.ReadLine();
                    Console.WriteLine("Введите bugs");
                    int bugs = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Введите cost");
                    double cost = Convert.ToDouble(Console.ReadLine());
                    Console.WriteLine("Введите licenseAgreement");
                    String licenseAgreement = Console.ReadLine();

                    if (licenseAgreement.Equals("0"))
                    {
                        list2.AddFirst(new Software(name, bugs, cost));
                        Console.WriteLine("Done");
                        Console.WriteLine("создали Software");
                    }
                    else
                    {
                        list2.AddFirst(new Game(name, bugs, cost, licenseAgreement));
                        Console.WriteLine("Done");
                        Console.WriteLine("создали Game");
                    }
                    Console.WriteLine("И добавили в list2");

                    Console.ReadLine();
                    break;
                }

                //LinkedList добавление элемента по указанному индексу
                case (13):
                {
                    Console.Clear();
                    try
                    {
                        Console.WriteLine("Теперь создаем обьект");
                        Console.WriteLine("Введите name");
                        String name = Console.ReadLine();
                        Console.WriteLine("Введите bugs");
                        int bugs = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("Введите cost");
                        double cost = Convert.ToDouble(Console.ReadLine());
                        Console.WriteLine("Введите licenseAgreement");
                        String licenseAgreement = Console.ReadLine();
                        Console.WriteLine("Введите index обьекта после котрого вставим этот");
                        int          index = Convert.ToInt32(Console.ReadLine());
                        IncreaseCost obj   = list2.ElementAt(index);


                        if (licenseAgreement.Equals("0"))
                        {
                            list2.AddAfter(list2.Find(obj), new Software(name, bugs, cost));
                            Console.WriteLine("Done");
                            Console.WriteLine("создали Software");
                        }
                        else
                        {
                            list2.AddAfter(list2.Find(obj), new Game(name, bugs, cost, licenseAgreement));
                            Console.WriteLine("Done");
                            Console.WriteLine("создали Game");
                        }
                        Console.WriteLine("И добавили в list2");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Не могу выполнить");
                    }

                    Console.ReadLine();
                    break;
                }

                //LinkedList нахождение элемента с начала коллекции
                case (14):
                {
                    Console.Clear();

                    Console.WriteLine("Находим элемент по имени name с начала");
                    Console.WriteLine("Введите name");
                    String   name    = Console.ReadLine();
                    Software finding = null;

                    LinkedListNode <IncreaseCost> node = list2.First;
                    for (int i = 0; i < list2.Count; i++)
                    {
                        IncreaseCost obj = node.Value;
                        if (name.Equals(((Software)obj).getName()))
                        {
                            finding = (Software)obj;
                        }
                        node = node.Next;
                    }

                    if (finding != null)
                    {
                        Console.WriteLine("Нашел");
                        if (finding is Game)
                        {
                            Console.WriteLine(((Game)finding).ToString());
                        }
                        else
                        {
                            Console.WriteLine(((Software)finding).ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("Не нашел");
                    }

                    Console.ReadLine();
                    break;
                }

                //LinkedList нахождение элемента с конца коллекции
                case (15):
                {
                    Console.Clear();

                    Console.WriteLine("Находим элемент по имени name с начала");
                    Console.WriteLine("Введите name");
                    String   name    = Console.ReadLine();
                    Software finding = null;

                    LinkedListNode <IncreaseCost> node = list2.Last;
                    for (int i = 0; i < list2.Count; i++)
                    {
                        IncreaseCost obj = node.Value;
                        if (name.Equals(((Software)obj).getName()))
                        {
                            finding = (Software)obj;
                        }
                        node = node.Previous;
                    }

                    if (finding != null)
                    {
                        Console.WriteLine("Нашел");
                        if (finding is Game)
                        {
                            Console.WriteLine(((Game)finding).ToString());
                        }
                        else
                        {
                            Console.WriteLine(((Software)finding).ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("Не нашел");
                    }

                    Console.ReadLine();
                    break;
                }

                //LinkedList удаление элемента по индексу
                case (16):
                {
                    Console.Clear();

                    try
                    {
                        Console.WriteLine("Удалим элемент по индексу");
                        Console.WriteLine("Введите индекс");
                        int index = Convert.ToInt32(Console.ReadLine());
                        list2.Remove(list2.ElementAt(index));
                        Console.WriteLine("Эх жаль элемента");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Че-то пошло не так :)");
                    }

                    Console.ReadLine();
                    break;
                }

                //LinkedList удаление элемента по значению
                case (17):
                {
                    Console.Clear();

                    try
                    {
                        Console.WriteLine("Удалим элемент по значению");
                        Console.WriteLine("Введите name");
                        String name = Console.ReadLine();
                        LinkedListNode <IncreaseCost> node = list2.First;
                        for (int i = 0; i < list2.Count; i++)
                        {
                            IncreaseCost obj = node.Value;
                            if (name.Equals(((Software)obj).getName()))
                            {
                                list2.Remove(obj);
                                Console.WriteLine("Эх жаль элемента");
                                break;
                            }
                            node = node.Next;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Че-то пошло не так :)");
                    }

                    Console.ReadLine();
                    break;
                }

                //LinkedList реверс коллекции
                case (18):
                {
                    Console.Clear();

                    Console.WriteLine("Произведем реверс list2");
                    IncreaseCost[]            array = list2.ToArray();
                    LinkedList <IncreaseCost> list3 = new LinkedList <IncreaseCost>();
                    foreach (IncreaseCost obj in list2)
                    {
                        list3.AddFirst(obj);
                    }
                    list2 = list3;
                    Console.WriteLine("Готово :)");

                    Console.ReadLine();
                    break;
                }

                //LinkedList сортировка
                case (19):
                {
                    Console.Clear();

                    Console.WriteLine("Отсортируем по name list2");
                    IncreaseCost[] array = new IncreaseCost[list2.Count];
                    int            i     = 0;
                    foreach (IncreaseCost obj in list2)
                    {
                        array[i] = obj;
                        i++;
                    }
                    Array.Sort(array);
                    list2.Clear();
                    for (int q = 0; q < array.Length; q++)
                    {
                        list2.AddLast(array[q]);
                    }
                    Console.WriteLine("Готово )");

                    Console.ReadLine();
                    break;
                }

                //выполнение методов всех объектов, поддерживающих Interface2
                case (20):
                {
                    Console.Clear();

                    foreach (IncreaseCost obj in list2)
                    {
                        if (obj is DecreaseCost)
                        {
                            Console.WriteLine("Ура");
                            Console.WriteLine("************************************************************");
                            ((DecreaseCost)obj).decreaseCost();
                            ((DecreaseCost)obj).information();
                            ((DecreaseCost)obj).statistic();
                            ((DecreaseCost)obj).info();
                        }
                    }

                    Console.ReadLine();
                    break;
                }



                case (0):
                {
                    Console.Clear();
                    break;
                }
                }
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            #region Delegate
            //Action test1 = () => { Console.WriteLine("test 1"); };
            //Action test2 = () => { Console.WriteLine("test 2"); };

            //Action action = test1;

            ////foreach (byte b in test1.Method.GetMethodBody().GetILAsByteArray())
            ////	Console.WriteLine(b);
            ////
            ////foreach (System.Reflection.FieldInfo field in typeof(Action).GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public))
            ////	Console.WriteLine(field);

            //action();
            ////Console.WriteLine(typeof(Action).GetField("_target", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(action));

            //IntPtr methodPtr = (IntPtr)typeof(Action).GetField("_methodPtr", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2);
            //IntPtr methodPtrAux = (IntPtr)typeof(Action).GetField("_methodPtrAux", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2);
            //object target = typeof(Action).GetField("_target", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2);
            //object methodBase = typeof(Action).GetField("_methodBase", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2);

            ////typeof(Action).GetField("_methodPtr", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(action, methodPtr);
            ////typeof(Action).GetField("_methodPtrAux", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(action, methodPtrAux);
            ////typeof(Action).GetField("_target", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(action, target);
            ////typeof(Action).GetField("_methodBase", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(action, methodBase);

            //byte[] array = test1.Method.GetMethodBody().GetILAsByteArray();
            //System.Runtime.InteropServices.GCHandle pinnedArray = System.Runtime.InteropServices.GCHandle.Alloc(array, System.Runtime.InteropServices.GCHandleType.Pinned);
            //IntPtr pointer = pinnedArray.AddrOfPinnedObject();

            //typeof(Action).GetField("_methodPtrAux", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(action, pointer);

            //pinnedArray.Free();

            //action();
            ////Console.WriteLine(typeof(Action).GetField("_target", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(action));

            //System.Action<System.String, System.Int32, System.Double>
            //System.Action`3[System.String, System.Int32, System.Double]

            //int i = 0;
            //foreach (string s in "Action<int, double, decimal>".Split('<', '>'))
            //	Console.WriteLine(i++ + " "+ s);

            //Console.WriteLine(string.IsNullOrWhiteSpace("Action<int, double, decimal>".Split('<', '>')["Action<int, double, decimal>".Split('<', '>').Length - 1]));

            //Console.WriteLine(Type.GetType("System.Action`3[System.String, System.Int32, System.Double]"));
            //Console.WriteLine(Type.GetType("Action<int>"));
            //Console.WriteLine(typeof(Action<int>).Name);
            //Console.WriteLine(typeof(Action<float>).Name);
            //Console.WriteLine(typeof(Action<double>).Name);
            //Console.WriteLine(typeof(Action<decimal>).Name);
            //Console.WriteLine(typeof(System.Collections.Generic.List<int>).Name);
            //Console.WriteLine(typeof(System.Collections.Generic.List<float>).Name);
            //Console.WriteLine(typeof(System.Collections.Generic.List<double>).Name);
            //Console.WriteLine(typeof(System.Collections.Generic.List<decimal>).Name);

            //Console.WriteLine(Type.GetType("List'1"));

            //Action test2 = Test;

            //Console.WriteLine(typeof(Action).GetField("_methodPtr", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2));
            //Console.WriteLine(typeof(Action).GetField("_methodPtrAux", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2));
            //Console.WriteLine(typeof(Action).GetField("_target", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2));
            //Console.WriteLine(typeof(Action).GetField("_methodBase", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(test2));
            //Console.WriteLine(test2.Truncate().Target);
            //Console.WriteLine(test2.Truncate().Method.DeclaringType.Name);

            //Action d = (Action)Delegate.CreateDelegate(typeof(Action), test2.Method);

            //114
            //1
            //0
            //0
            //112
            //40
            //22
            //0
            //0
            //10
            //42
            //System.Object _target
            //System.Object _methodBase
            //IntPtr _methodPtr
            //IntPtr _methodPtrAux


            #endregion

            #region Random Generators

            //int iterationsperrandom = 3;
            //Action<Random> testrandom = (Random random) =>
            //	{
            //		for (int i = 0; i < iterationsperrandom; i++)
            //			Console.WriteLine(i + ": " + random.Next());
            //		Console.WriteLine();
            //	};
            //Arbitrary mcg_2pow59_13pow13 = Arbitrary.MultiplicativeCongruentGenerator_Modulus2power59_Multiplier13power13();
            //Console.WriteLine("mcg_2pow59_13pow13 randoms:");
            //testrandom(mcg_2pow59_13pow13);
            //Arbitrary mcg_2pow31m1_1132489760 = Arbitrary.MultiplicativeCongruentGenerator_Modulus2power31minus1_Multiplier1132489760();
            //Console.WriteLine("mcg_2pow31m1_1132489760 randoms:");
            //testrandom(mcg_2pow31m1_1132489760);
            //Arbitrary mersenneTwister = Arbitrary.MersenneTwister();
            //Console.WriteLine("mersenneTwister randoms:");
            //testrandom(mersenneTwister);
            //Arbitrary cmr32_c2_o3 = Arbitrary.CombinedMultipleRecursiveGenerator32bit_components2_order3();
            //Console.WriteLine("mersenneTwister randoms:");
            //testrandom(cmr32_c2_o3);
            //Arbitrary wh1982cmcg = Arbitrary.WichmannHills1982_CombinedMultiplicativeCongruentialGenerator();
            //Console.WriteLine("mersenneTwister randoms:");
            //testrandom(wh1982cmcg);
            //Arbitrary wh2006cmcg = Arbitrary.WichmannHills2006_CombinedMultiplicativeCongruentialGenerator();
            //Console.WriteLine("mersenneTwister randoms:");
            //testrandom(wh2006cmcg);
            //Arbitrary mwcxorsg = Arbitrary.MultiplyWithCarryXorshiftGenerator();
            //Console.WriteLine("mwcxorsg randoms:");
            //testrandom(mwcxorsg);

            #endregion

            #region Set Tests
            //{
            //	int iterations = int.MaxValue / 1000;

            //	HashSet<int> validation = new HashSet<int>();
            //	//for (int i = 0; i < interations; i++)
            //	//	validation.Add(i);

            //	{
            //		HashSet<int> set0 = new HashSet<int>();
            //		SetHashList<int> set1 = new SetHashList<int>();
            //		SetHashArray<int> set2 = new SetHashArray<int>();

            //		for (int i = 0; i < iterations; i++) set0.Add(i);
            //		for (int i = 0; i < iterations; i++) set1.Add(i);
            //		for (int i = 0; i < iterations; i++) set2.Add(i);
            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		foreach (int i in set0) { validation.Remove(i); }
            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set1.Stepper((int i) => { validation.Remove(i); });
            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set2.Stepper((int i) => { validation.Remove(i); });
            //		for (int i = 0; i < iterations; i++) set0.Contains(i);
            //		for (int i = 0; i < iterations; i++) set1.Contains(i);
            //		for (int i = 0; i < iterations; i++) set2.Contains(i);
            //		for (int i = 0; i < iterations; i++) set0.Remove(i);
            //		for (int i = 0; i < iterations; i++) set1.Remove(i);
            //		for (int i = 0; i < iterations; i++) set2.Remove(i);

            //		Console.WriteLine("Adding HashSet:               " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = 0; i < iterations; i++) set0.Add(i); }));
            //		Console.WriteLine("Adding Set_HashLinkedList:    " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = 0; i < iterations; i++) set1.Add(i); }));
            //		Console.WriteLine("Adding SetHash:               " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = 0; i < iterations; i++) set2.Add(i); }));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		foreach (int i in set0) { validation.Remove(i); }
            //		Console.WriteLine("Validate HashSet:             " + (validation.Count == 0));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set1.Stepper((int i) => { validation.Remove(i); });
            //		Console.WriteLine("Validate Set_HashLinkedList:  " + (validation.Count == 0));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set2.Stepper((int i) => { validation.Remove(i); });
            //		Console.WriteLine("Validate SetHas:              " + (validation.Count == 0));

            //		Console.WriteLine("Size HashSet:                 " + (typeof(HashSet<int>).GetField("m_buckets", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(set0) as int[]).Length);
            //		Console.WriteLine("Size Set_HashLinkedList:      " + set1.TableSize);
            //		Console.WriteLine("Size SetHash:                 " + set2.TableSize);

            //		Console.WriteLine("Constains HashSet:            " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = 0; i < iterations; i++) set0.Contains(i); }));
            //		Console.WriteLine("Constains Set_HashLinkedList: " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = 0; i < iterations; i++) set1.Contains(i); }));
            //		Console.WriteLine("Constains SetHash:            " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = 0; i < iterations; i++) set2.Contains(i); }));

            //		//Console.WriteLine("Removed HashSet:              " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) set0.Remove(i); }));
            //		//Console.WriteLine("Removed Set_HashLinkedList:   " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) set1.Remove(i); }));
            //		//Console.WriteLine("Remove SetHash:               " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) set2.Remove(i); }));

            //		Console.WriteLine("Removed HashSet:              " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = iterations - 1; i >= 0; i--) set0.Remove(i); }));
            //		Console.WriteLine("Removed Set_HashLinkedList:   " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = iterations - 1; i >= 0; i--) set1.Remove(i); }));
            //		Console.WriteLine("Remove SetHash:               " + Seven.Diagnostics.Performance.Time_DateTimNow(() => { for (int i = iterations - 1; i >= 0; i--) set2.Remove(i); }));

            //		Console.WriteLine("Size HashSet:                 " + (typeof(HashSet<int>).GetField("m_buckets", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(set0) as int[]).Length);
            //		Console.WriteLine("Size Set_HashLinkedList:      " + set1.TableSize);
            //		Console.WriteLine("Size SetHash:                 " + set2.TableSize);
            //	}
            //	Console.WriteLine();
            //	{
            //		HashSet<int> set0 = new HashSet<int>();
            //		SetHashList<int> set1 = new SetHashList<int>();
            //		SetHashArray<int> set2 = new SetHashArray<int>();

            //		for (int i = 0; i < iterations; i++) set0.Add(i);
            //		for (int i = 0; i < iterations; i++) set1.Add(i);
            //		for (int i = 0; i < iterations; i++) set2.Add(i);
            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		foreach (int i in set0) { validation.Remove(i); }
            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set1.Stepper((int i) => { validation.Remove(i); });
            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set2.Stepper((int i) => { validation.Remove(i); });
            //		for (int i = 0; i < iterations; i++) set0.Contains(i);
            //		for (int i = 0; i < iterations; i++) set1.Contains(i);
            //		for (int i = 0; i < iterations; i++) set2.Contains(i);
            //		for (int i = 0; i < iterations; i++) set0.Remove(i);
            //		for (int i = 0; i < iterations; i++) set1.Remove(i);
            //		for (int i = 0; i < iterations; i++) set2.Remove(i);

            //		Console.WriteLine("Adding HashSet:               " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = 0; i < iterations; i++) set0.Add(i); }));
            //		Console.WriteLine("Adding Set_HashLinkedList:    " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = 0; i < iterations; i++) set1.Add(i); }));
            //		Console.WriteLine("Adding SetHash:               " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = 0; i < iterations; i++) set2.Add(i); }));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		foreach (int i in set0) { validation.Remove(i); }
            //		Console.WriteLine("Validate HashSet:             " + (validation.Count == 0));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set1.Stepper((int i) => { validation.Remove(i); });
            //		Console.WriteLine("Validate Set_HashLinkedList:  " + (validation.Count == 0));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		set2.Stepper((int i) => { validation.Remove(i); });
            //		Console.WriteLine("Validate SetHas:              " + (validation.Count == 0));

            //		Console.WriteLine("Size HashSet:                 " + (typeof(HashSet<int>).GetField("m_buckets", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(set0) as int[]).Length);
            //		Console.WriteLine("Size Set_HashLinkedList:      " + set1.TableSize);
            //		Console.WriteLine("Size SetHash:                 " + set2.TableSize);

            //		Console.WriteLine("Constains HashSet:            " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = 0; i < iterations; i++) set0.Contains(i); }));
            //		Console.WriteLine("Constains Set_HashLinkedList: " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = 0; i < iterations; i++) set1.Contains(i); }));
            //		Console.WriteLine("Constains SetHash:            " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = 0; i < iterations; i++) set2.Contains(i); }));

            //		//Console.WriteLine("Removed HashSet:              " + Seven.Diagnostics.Performance.Time2(() => { for (int i = 0; i < iterations; i++) set0.Remove(i); }));
            //		//Console.WriteLine("Removed Set_HashLinkedList:   " + Seven.Diagnostics.Performance.Time2(() => { for (int i = 0; i < iterations; i++) set1.Remove(i); }));
            //		//Console.WriteLine("Remove SetHash:               " + Seven.Diagnostics.Performance.Time2(() => { for (int i = 0; i < iterations; i++) set2.Remove(i); }));

            //		Console.WriteLine("Removed HashSet:              " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = iterations - 1; i >= 0; i--) set0.Remove(i); }));
            //		Console.WriteLine("Removed Set_HashLinkedList:   " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = iterations - 1; i >= 0; i--) set1.Remove(i); }));
            //		Console.WriteLine("Remove SetHash:               " + Seven.Diagnostics.Performance.Time_StopWatch(() => { for (int i = iterations - 1; i >= 0; i--) set2.Remove(i); }));

            //		Console.WriteLine("Size HashSet:                 " + (typeof(HashSet<int>).GetField("m_buckets", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(set0) as int[]).Length);
            //		Console.WriteLine("Size Set_HashLinkedList:      " + set1.TableSize);
            //		Console.WriteLine("Size SetHash:                 " + set2.TableSize);
            //	}

            //	Console.WriteLine();
            //}
            #endregion

            #region Map/Dictionary
            //{
            //	int iterations = int.MaxValue / 10000;

            //	HashSet<int> validation = new HashSet<int>();
            //	//for (int i = 0; i < interations; i++)
            //	//	validation.Add(i);

            //	{
            //		Dictionary<int, int> map0 = new Dictionary<int, int>();
            //		//MapSetHashList<int, int> map1 = new MapSetHashList<int, int>();
            //		MapHashLinked<int, int> map2 = new MapHashLinked<int, int>();
            //		MapHashArray<int, int> map3 = new MapHashArray<int, int>();


            //		Console.WriteLine("Adding 0:    " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map0.Add(i, i); }));
            //		//Console.WriteLine("Adding 1:    " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map1.Add(i, i); }));
            //		Console.WriteLine("Adding 2:    " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map2.Add(i, i); }));
            //		Console.WriteLine("Adding 3:    " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map3.Add(i, i); }));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		foreach (KeyValuePair<int, int> i in map0) { validation.Remove(i.Key); }
            //		Console.WriteLine("Validate 0:  " + (validation.Count == 0));

            //		//for (int i = 0; i < iterations; i++)
            //		//	validation.Add(i);
            //		////foreach (int i in map1) { validation.Remove(i); }
            //		//map1.Stepper((int i) => { validation.Remove(i); });
            //		//Console.WriteLine("Validate 1:  " + (validation.Count == 0));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		//foreach (int i in map1) { validation.Remove(i); }
            //		map2.Stepper((int i) => { validation.Remove(i); });
            //		Console.WriteLine("Validate 2:  " + (validation.Count == 0));

            //		for (int i = 0; i < iterations; i++)
            //			validation.Add(i);
            //		//foreach (int i in map1) { validation.Remove(i); }
            //		map3.Stepper((int i) => { validation.Remove(i); });
            //		Console.WriteLine("Validate 3:  " + (validation.Count == 0));

            //		int temp;
            //		Console.WriteLine("Get 0:       " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) temp = map0[i]; }));
            //		//Console.WriteLine("Get 1:       " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) temp = map1[i]; }));
            //		Console.WriteLine("Get 2:       " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) temp = map2[i]; }));
            //		Console.WriteLine("Get 3:       " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) temp = map3[i]; }));

            //		Console.WriteLine("Removed 0:   " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map0.Remove(i); }));
            //		//Console.WriteLine("Removed 1:   " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map1.Remove(i); }));
            //		Console.WriteLine("Removed 2:   " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map2.Remove(i); }));
            //		Console.WriteLine("Removed 3:   " + Seven.Diagnostics.Performance.Time(() => { for (int i = 0; i < iterations; i++) map3.Remove(i); }));
            //	}
            //}
            #endregion

            #region Vector Test

            //Console.WriteLine();
            //Console.WriteLine("Vector Testing-------------------------------------");

            //Random random = new Random();
            //const int vector_size = 4;
            //const int vector_iterations = int.MaxValue / 100;

            //Vector<double> vector_a = new Vector<double>(vector_size);
            //Vector<double> vector_b = new Vector<double>(vector_size);
            //Vector<double> vector_c;

            //for (int i = 0; i < vector_size; i++)
            //{
            //	vector_a[i] = random.Next();
            //	vector_b[i] = random.Next();
            //}

            //Console.WriteLine("Compile 1: " + Seven.Diagnostics.Performance.Time(() => { vector_c = Vector<double>.Vector_Add(vector_a, vector_b); }));
            //Console.WriteLine("Compile 2: " + Seven.Diagnostics.Performance.Time(() => { vector_c = Vector<double>.Vector_Add2(vector_a, vector_b); }));
            //Console.WriteLine("Compile 3: " + Seven.Diagnostics.Performance.Time(() => { vector_c = Vector<double>.Vector_Add3(vector_a, vector_b); }));
            //Console.WriteLine("Compile 4: " + Seven.Diagnostics.Performance.Time(() => { vector_c = Vector<double>.Vector_Add4(vector_a, vector_b); }));

            //Console.WriteLine("Test 1:    " + Seven.Diagnostics.Performance.Time(() => {
            //	for (int i = 0; i < vector_iterations; i++)
            //		vector_c = Vector<double>.Vector_Add(vector_a, vector_b);
            //}));

            //Console.WriteLine("Test 2:    " + Seven.Diagnostics.Performance.Time(() =>
            //{
            //	for (int i = 0; i < vector_iterations; i++)
            //		vector_c = Vector<double>.Vector_Add2(vector_a, vector_b);
            //}));

            //Console.WriteLine("Test 3:    " + Seven.Diagnostics.Performance.Time(() =>
            //{
            //	for (int i = 0; i < vector_iterations; i++)
            //		vector_c = Vector<double>.Vector_Add3(vector_a, vector_b);
            //}));

            //Console.WriteLine("Test 4:    " + Seven.Diagnostics.Performance.Time(() =>
            //{
            //	for (int i = 0; i < vector_iterations; i++)
            //		vector_c = Vector<double>.Vector_Add4(vector_a, vector_b);
            //}));

            #endregion

            #region Sorting Speed
            //{
            //	int size = int.MaxValue / 1000000;
            //	int[] dataSet = new int[size];
            //	for (int i = 0; i < size; i++)
            //		dataSet[i] = i;

            //	Console.WriteLine("Sorting Algorithms----------------------");
            //	Console.WriteLine();

            //	//Sort<int>.Shuffle(dataSet);
            //	//Console.Write("Bubble:      " + Seven.Diagnostics.Performance.Time(() => { Sort<int>.Bubble(dataSet); }));
            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("Selection:   " + Seven.Diagnostics.Performance.Time(() => { Sort<int>.Selection(dataSet); }));
            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("Insertion:   " + Seven.Diagnostics.Performance.Time(() => { Sort<int>.Insertion(dataSet); }));
            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("Quick:       " + Seven.Diagnostics.Performance.Time(() => { Sort<int>.Quick(dataSet); }));
            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("Merge:       " + Seven.Diagnostics.Performance.Time(() => { Sort<int>.Merge(dataSet); }));
            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("Heap:        " + Seven.Diagnostics.Performance.Time(() => { Sort<int>.Heap(dataSet); }));
            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("OddEven:     " + Seven.Diagnostics.Performance.Time(() => { Sort<int>.OddEven(dataSet); }));

            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("IEnumerable: " + Seven.Diagnostics.Performance.Time(() => { dataSet.OrderBy(item => item); }));
            //	Sort<int>.Shuffle(dataSet);
            //	Console.WriteLine("Array.Sort:  " + Seven.Diagnostics.Performance.Time(() => { Array.Sort(dataSet); }));
            //}
            #endregion

            #region Matrix Test

            //Random random = new Random();
            //const int matrix_rows = 4;
            //const int matrix_columns = 4;
            //const int matrix_iterations = int.MaxValue / 100;

            //{

            //	Seven.Mathematics.Matrix<double> matrix_a = new Seven.Mathematics.Matrix<double>(matrix_rows, matrix_columns);
            //	Seven.Mathematics.Matrix<double> matrix_b = new Seven.Mathematics.Matrix<double>(matrix_rows, matrix_columns);
            //	Seven.Mathematics.Matrix<double> matrix_c;

            //	matrix_c = matrix_a + matrix_b;
            //	matrix_c = matrix_b + matrix_a;
            //	//matrix_a = matrix_b + matrix_c;
            //	//matrix_a = matrix_c + matrix_b;

            //	for (int i = 0; i < matrix_rows; i++)
            //		for (int j = 0; j < matrix_columns; j++)
            //		{
            //			matrix_a[i, j] = random.Next();
            //			matrix_b[i, j] = random.Next();
            //		}

            //	Console.WriteLine("Test 1:    " + Seven.Diagnostics.Performance.Time(() =>
            //	{
            //		for (int i = 0; i < matrix_iterations; i++)
            //			matrix_c = matrix_a + matrix_b;
            //	}));

            //matrix_c = Matrix<double>.Matrix_Negate2(matrix_a);
            //Console.WriteLine("Test 2:    " + Seven.Diagnostics.Performance.Time(() =>
            //{
            //	for (int i = 0; i < matrix_iterations; i++)
            //		matrix_c = Matrix<double>.Matrix_Negate2(matrix_a);
            //}));

            //Console.WriteLine("Test 2:    " + Seven.Diagnostics.Performance.Time(() =>
            //{
            //	for (int i = 0; i < matrix_iterations; i++)
            //		Matrix<double>.Matrix_IsSymetric2(matrix_a);
            //}));

            //Console.WriteLine("Compile 1: " + Seven.Diagnostics.Performance.Time(() => { matrix_c = matrix_a + matrix_b; }));

            //Console.WriteLine("Test 1:    " + Seven.Diagnostics.Performance.Time(() =>
            //{
            //	for (int i = 0; i < matrix_iterations; i++)
            //		matrix_c = matrix_a + matrix_b;
            //}));

            //}

            #endregion

            #region Omnitree

            Omnitree.Locate <TestObject, double> locate = (TestObject record) =>
            {
                return((int i) =>
                {
                    switch (i)
                    {
                    case 0:
                        return record.X;

                    case 1:
                        return record.Y;

                    case 2:
                        return record.Z;

                    default:
                        throw new System.Exception();
                    }
                });
            };

            Compute <double> .Compare(0, 0);

            Omnitree <TestObject, double> omnitree = new OmnitreeLinked <TestObject, double>(
                3,
                Accessor.Get(new double[] { 0, 0, 0 }),
                Accessor.Get(new double[] { 1, 1, 1 }),
                locate,
                (double a, double b) => { return(a == b); },
                Equate.Default,
                Compute <double> .Compare,
                (double a, double b) => { return((a + b) / 2); });

            System.Collections.Generic.List <TestObject> list = new System.Collections.Generic.List <TestObject>();

            System.Collections.Generic.LinkedList <TestObject> linkedlist = new System.Collections.Generic.LinkedList <TestObject>();

            Random       random  = new Random(7);
            int          count   = 10000;
            TestObject[] records = new TestObject[count];
            for (int i = 0; i < count; i++)
            {
                records[i] = new TestObject(i, random.NextDouble(), random.NextDouble(), random.NextDouble());
            }

            Console.WriteLine("Testing with " + count + " records...");
            Console.WriteLine();

            Console.WriteLine("Adding (Omnitree):          " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < count; i++)
                {
                    omnitree.Add(records[i]);
                }
            }));

            Console.WriteLine("Adding (List):              " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < count; i++)
                {
                    list.Add(records[i]);
                }
            }));

            Console.WriteLine("Adding (L-List):            " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < count; i++)
                {
                    linkedlist.AddLast(records[i]);
                }
            }));

            Console.WriteLine();

            Sort <TestObject> .Shuffle(random, Accessor.Get(records), Accessor.Assign(records), 0, records.Length);

            Console.WriteLine("Querying Single (Omnitree): " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                bool query_test;
                for (int i = 0; i < count; i++)
                {
                    query_test = false;
                    omnitree[locate(records[i])]((TestObject record) => { query_test = true; });
                    //omnitree[records[i].X, records[i].Y, records[i].Z]((TestObject record) => { query_test = true; });
                    if (query_test == false)
                    {
                        throw new System.Exception();
                    }
                }
            }));

            Console.WriteLine("Querying Single (List):     " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                bool query_test = false;
                for (int i = 0; i < count; i++)
                {
                    foreach (TestObject record in list)
                    {
                        if (record.X == records[i].X && record.Y == records[i].Y && record.Z == records[i].Z)
                        {
                            query_test = true;
                            break;
                        }
                    }
                    if (query_test == false)
                    {
                        throw new System.Exception();
                    }
                }
            }));

            Console.WriteLine("Querying Single (L-List):   " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                bool query_test = false;
                for (int i = 0; i < count; i++)
                {
                    foreach (TestObject record in linkedlist)
                    {
                        if (record.X == records[i].X && record.Y == records[i].Y && record.Z == records[i].Z)
                        {
                            query_test = true;
                            break;
                        }
                    }
                    if (query_test == false)
                    {
                        throw new System.Exception();
                    }
                }
            }));

            Console.WriteLine();

            int        random_query_count = count / 100;
            double[][] random_mins        = new double[random_query_count][];
            for (int i = 0; i < random_query_count; i++)
            {
                random_mins[i] = new double[] { random.NextDouble(), random.NextDouble(), random.NextDouble(), }
            }
            ;
            double[][] random_maxes = new double[random_query_count][];
            for (int i = 0; i < random_query_count; i++)
            {
                random_maxes[i] = new double[] {
                    random.NextDouble() *((1 - random_mins[i][0]) + random_mins[i][0]),
                    random.NextDouble() * ((1 - random_mins[i][1]) + random_mins[i][1]),
                    random.NextDouble() * ((1 - random_mins[i][2]) + random_mins[i][2])
                }
            }
            ;

            Console.WriteLine(random_query_count + " random range queries...");

            int[] query_count_omnitree   = new int[random_query_count];
            int[] query_count_list       = new int[random_query_count];
            int[] query_count_linkedlist = new int[random_query_count];

            Console.WriteLine("Querying Range (Omnitree):  " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < random_query_count; i++)
                {
                    omnitree.Stepper((TestObject record) => { query_count_omnitree[i]++; }, random_mins[i], random_maxes[i]);
                }
            }));

            Console.WriteLine("Querying Range (List):      " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < random_query_count; i++)
                {
                    foreach (TestObject record in list)
                    {
                        if (record.X >= random_mins[i][0] && record.X <= random_maxes[i][0] &&
                            record.Y >= random_mins[i][1] && record.Y <= random_maxes[i][1] &&
                            record.Z >= random_mins[i][2] && record.Z <= random_maxes[i][2])
                        {
                            query_count_list[i]++;
                        }
                    }
                }
            }));

            Console.WriteLine("Querying Range (L-List):    " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < random_query_count; i++)
                {
                    foreach (TestObject record in linkedlist)
                    {
                        if (record.X >= random_mins[i][0] && record.X <= random_maxes[i][0] &&
                            record.Y >= random_mins[i][1] && record.Y <= random_maxes[i][1] &&
                            record.Z >= random_mins[i][2] && record.Z <= random_maxes[i][2])
                        {
                            query_count_linkedlist[i]++;
                        }
                    }
                }
            }));

            for (int i = 0; i < random_query_count; i++)
            {
                if (query_count_omnitree[i] != query_count_list[i] || query_count_list[i] != query_count_linkedlist[i])
                {
                    throw new System.Exception();
                }
            }

            Console.WriteLine();

            foreach (TestObject record in records)
            {
                record.X += Math.Max(0d, Math.Min(1d, (random.NextDouble() / 100D) - .5D));
                record.Y += Math.Max(0d, Math.Min(1d, (random.NextDouble() / 100D) - .5D));
                record.Z += Math.Max(0d, Math.Min(1d, (random.NextDouble() / 100D) - .5D));
            }

            Console.WriteLine("Updating (Omnitree):        " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                omnitree.Update();
            }));

            Console.WriteLine();

            Console.WriteLine("Removing Single (Omnitree): " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < count; i++)
                {
                    //// Removal Method #1
                    omnitree.Remove(records[i]);

                    //// Removal Method #2
                    //omnitree.Remove(locate(records[i]), locate(records[i]));

                    //// Removal Method #3
                    //omnitree.Remove(locate(records[i]), locate(records[i]), (TestObject step) => { return records[i].Id == step.Id; });

                    //// Removal Method #4
                    //double[] location = new double[] { locate(records[i])(0), locate(records[i])(1), locate(records[i])(2) };
                    //omnitree.Remove(location, location);

                    //// Removal Method #5
                    //double[] location = new double[] { locate(records[i])(0), locate(records[i])(1), locate(records[i])(2) };
                    //omnitree.Remove(location, location, (omnitree_record step) => { return records[i].Id == step.Id; });
                }
            }));

            Console.WriteLine("Removing Single (List):     " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < count; i++)
                {
                    //list.Remove(records[i]);

                    for (int j = 0; j < list.Count; j++)
                    {
                        if (list[j].X == records[i].X && list[j].Y == records[i].Y && list[j].Z == records[i].Z)
                        {
                            list.RemoveAt(j);
                            break;
                        }
                    }
                }
            }));

            Console.WriteLine("Removing Single (L-List):   " + Seven.Diagnostics.Performance.Time_StopWatch(() =>
            {
                for (int i = 0; i < count; i++)
                {
                    //linkedlist.Remove(records[i]);

                    LinkedList <TestObject> temp = new LinkedList <TestObject>();
                    foreach (TestObject record in linkedlist)
                    {
                        if (record.X == records[i].X && record.Y == records[i].Y && record.Z == records[i].Z)
                        {
                            temp.AddLast(record);
                            break;
                        }
                    }
                    foreach (TestObject record in temp)
                    {
                        linkedlist.Remove(record);
                    }
                }
            }));

            for (int i = 0; i < count; i++)
            {
                omnitree.Add(records[i]);
                list.Add(records[i]);
                linkedlist.AddLast(records[i]);
            }

            Console.WriteLine();

            TimeSpan omnitree_remove_span = TimeSpan.Zero;
            for (int i = 0; i < random_query_count; i++)
            {
                System.Collections.Generic.List <TestObject> temp = new System.Collections.Generic.List <TestObject>();
                omnitree[locate(records[i])]((TestObject record) => { temp.Add(record); });
                omnitree_remove_span += Seven.Diagnostics.Performance.Time_StopWatch(() =>
                {
                    omnitree.Remove(random_mins[i], random_maxes[i]);
                });
                foreach (TestObject record in temp)
                {
                    omnitree.Add(record);
                }
            }
            Console.WriteLine("Removing Range (Omnitree):  " + omnitree_remove_span);

            TimeSpan list_remove_span = TimeSpan.Zero;
            for (int i = 0; i < random_query_count; i++)
            {
                System.Collections.Generic.List <TestObject> temp = new System.Collections.Generic.List <TestObject>();

                foreach (TestObject record in list)
                {
                    if (record.X >= random_mins[i][0] && record.X <= random_maxes[i][0] &&
                        record.Y >= random_mins[i][1] && record.Y <= random_maxes[i][1] &&
                        record.Z >= random_mins[i][2] && record.Z <= random_maxes[i][2])
                    {
                        temp.Add(record);
                    }
                }

                list_remove_span += Seven.Diagnostics.Performance.Time_StopWatch(() =>
                {
                    list.RemoveAll((TestObject record) =>
                    {
                        return(record.X >= random_mins[i][0] && record.X <= random_maxes[i][0] &&
                               record.Y >= random_mins[i][1] && record.Y <= random_maxes[i][1] &&
                               record.Z >= random_mins[i][2] && record.Z <= random_maxes[i][2]);
                    });
                    //for (int j = 0; j < list.Count; j++)
                    //{
                    //	if (list[j].X >= random_mins[i][0] && list[j].X <= random_maxes[i][0] &&
                    //		list[j].Y >= random_mins[i][1] && list[j].Y <= random_maxes[i][1] &&
                    //		list[j].Z >= random_mins[i][2] && list[j].Z <= random_maxes[i][2])
                    //	{
                    //		list.RemoveAll.RemoveAt(i);
                    //	}
                    //}
                });
                foreach (TestObject record in temp)
                {
                    list.Add(record);
                }
            }
            Console.WriteLine("Removing Range (List):      " + list_remove_span);

            TimeSpan linkedlist_remove_span = TimeSpan.Zero;
            for (int i = 0; i < random_query_count; i++)
            {
                System.Collections.Generic.List <TestObject> temp = new System.Collections.Generic.List <TestObject>();

                foreach (TestObject record in linkedlist)
                {
                    if (record.X >= random_mins[i][0] && record.X <= random_maxes[i][0] &&
                        record.Y >= random_mins[i][1] && record.Y <= random_maxes[i][1] &&
                        record.Z >= random_mins[i][2] && record.Z <= random_maxes[i][2])
                    {
                        temp.Add(record);
                    }
                }

                linkedlist_remove_span += Seven.Diagnostics.Performance.Time_StopWatch(() =>
                {
                    System.Collections.Generic.List <TestObject> temp2 = new System.Collections.Generic.List <TestObject>();
                    foreach (TestObject record in linkedlist)
                    {
                        if (record.X >= random_mins[i][0] && record.X <= random_maxes[i][0] &&
                            record.Y >= random_mins[i][1] && record.Y <= random_maxes[i][1] &&
                            record.Z >= random_mins[i][2] && record.Z <= random_maxes[i][2])
                        {
                            temp2.Add(record);
                        }
                    }
                    foreach (TestObject record in temp2)
                    {
                        linkedlist.Remove(record);
                    }
                });
                foreach (TestObject record in temp)
                {
                    list.Add(record);
                }
            }
            Console.WriteLine("Removing Range (L-List):    " + linkedlist_remove_span);

            #endregion

            Console.WriteLine();
            Console.WriteLine("Done...");
            Console.ReadLine();
        }
    }
}