Beispiel #1
0
        private void WriteBySize(StreamWriter writer, ArrayList rulers)
        {
            writer.WriteLine("<h2>Top Rulers by Total {0}</h2>", "Size");
            writer.WriteLine("<table>");

            writer.WriteLine("<tr>");
            writer.WriteLine("<th>#</td>");
            writer.WriteLine("<th>Ruler</td>");
            writer.WriteLine("<th>Planets</td>");
            writer.WriteLine("<th>Avg</td>");
            writer.WriteLine("<th>{0}</td>", "Space");
            writer.WriteLine("</tr>");

            for (int i = 0; i < NumberOfRulers; ++i)
            {
                Ruler ruler = (Ruler)rulers[i];
                writer.WriteLine("<tr>");
                writer.WriteLine("<td>{0}</td>", i + 1);
                writer.WriteLine("<td>{0}</td>", OrionGlobals.getLink(ruler));
                writer.WriteLine("<td>{0}</td>", ruler.Planets.Length);

                int count = SizeComparer.Count(ruler);

                writer.WriteLine("<td>{0}</td>", OrionGlobals.format(count / ruler.Planets.Length));
                writer.WriteLine("<td>{0}</td>", OrionGlobals.format(count));
                writer.WriteLine("</tr>");
            }

            writer.WriteLine("</table>");
        }
Beispiel #2
0
        private void CustomSort(DataGrid dataGrid, DataGridColumn column, ListSortDirection listSortDirection)
        {
            IComparer comparer;

            if (column.Header.Equals("Name"))
            {
                comparer = new NameComparer(listSortDirection);
            }
            else if (column.Header.Equals("Size"))
            {
                comparer = new SizeComparer(listSortDirection);
            }
            else
            {
                comparer = new ModifiedComparer(listSortDirection);
            }
            column.SortDirection = listSortDirection;
            ListCollectionView collectionview = CollectionViewSource
                                                .GetDefaultView(dataGrid.ItemsSource) as ListCollectionView;

            if (collectionview != null)
            {
                collectionview.CustomSort = comparer;
            }
            else
            {
                return;
            }
        }
Beispiel #3
0
        public void Allocation(short processNumber, string criteria)
        {
            SizeComparer sc = new SizeComparer();
            SizeComparer bc = new SizeComparer();

            sc.SortBy = SizeComparer.SortCriteria.SmallFirst;
            bc.SortBy = SizeComparer.SortCriteria.BigFirst;

            int extraSpace = 0;

            if (criteria == "best-fit")
            {
                memory.Sort(sc);
                process.Sort(sc);
            }

            else if (criteria == "worst-fit")
            {
                memory.Sort(bc);
                process.Sort(sc);
            }

            for (int i = 0; i < processNumber; i++)
            {
                int     currentMemory = 0;
                Boolean fit           = false;
                while (fit == false)
                {
                    if (process[i].gSize <= memory[currentMemory].uSpace)
                    {
                        memory[currentMemory].uSpace = memory[currentMemory].uSpace - process[i].gSize;
                        fit = true;
                        //Display the output
                        Console.WriteLine("Process " + process[i].gName + " is in Memory block " + memory[currentMemory].gName);
                    }
                    else
                    {
                        currentMemory++;
                    }
                }
            }

            for (int i = 0; i < processNumber; i++)
            {
                extraSpace       = extraSpace + memory[i].uSpace;
                memory[i].uSpace = memory[i].gSize;
            }


            Console.WriteLine("Total unused space is " + extraSpace + ".\n");
        }
        public List <IEnumerable <ProductAttribute> > GetProductAttributes()
        {
            List <IEnumerable <ProductAttribute> > allAttributes = new List <IEnumerable <ProductAttribute> >();
            IEnumerable <ProductAttribute>         colours       = _repo.GetProductAttributes <Colour>();
            IEnumerable <ProductAttribute>         brands        = _repo.GetProductAttributes <Brand>();
            IEnumerable <ProductAttribute>         categories    = _repo.GetProductAttributes <ItemCategory>();
            SizeComparer sc       = new SizeComparer();
            List <Size>  sizeList = _repo.GetProductAttributes <Size>();

            sizeList.Sort(sc);
            IEnumerable <ProductAttribute> sizes = sizeList;

            allAttributes.Add(colours);
            allAttributes.Add(brands);
            allAttributes.Add(categories);
            allAttributes.Add(sizes);
            return(allAttributes);
        }
Beispiel #5
0
        /// <summary>
        /// Sets up the selected comparer.
        /// </summary>
        /// <param name="commandArgument">The command argument indicating what comparer to set up.</param>
        private void SetupSelectedComparer(string commandArgument)
        {
            SortingColumn = commandArgument;
            switch (commandArgument)
            {
            case "name":
                SelectedComparer = new NameComparer(Direction);
                break;

            case "size":
                SelectedComparer = new SizeComparer(Direction);
                break;

            case "checkedOut":
                SelectedComparer = new CheckedOutByComparer(Direction);
                break;

            case "lastChanged":
                SelectedComparer = new DateComparer(Direction);
                break;
            }
        }
Beispiel #6
0
        private void WikiWriteBySize(StreamWriter writer, ArrayList rulers)
        {
            writer.WriteLine("!!!Top Rulers by Total {0}", "Size");

            writer.Write("||{!^}*#*");
            writer.Write("||{!^}*Ruler*");
            writer.Write("||{!^}*Planets*");
            writer.Write("||{!^}*Avg*");
            writer.WriteLine("||{!^}*Space*||");

            for (int i = 0; i < NumberOfRulers; ++i)
            {
                Ruler ruler = (Ruler)rulers[i];
                writer.Write("||{0}", i + 1);
                writer.Write("||{0}", ruler.Name);
                writer.Write("||{0}", ruler.Planets.Length);

                int count = SizeComparer.Count(ruler);

                writer.Write("||{0}", OrionGlobals.format(count / ruler.Planets.Length));
                writer.WriteLine("||{0}||", OrionGlobals.format(count));
            }
        }