Example #1
0
        public IActionResult Numbers()
        {
            NumberArray newnumarr = new NumberArray()
            {
                numArr = new int[] { 1, 2, 3, 10, 43, 5 }
            };

            return(View("Numbers", newnumarr));
        }
Example #2
0
        public void TestCopyNumberArrayBlock()
        {
            VariableBlock[] blocks = new VariableBlock[2];
            blocks[0] = new Constant(10, "a", "", false);
            blocks[1] = new NumberArray("cake", blocks[0], "");

            int[][] dependencyGraph = new int[][]
            {
                new int[] { },
                new int[] { 0 }
            };

            CheckCopyMultiBlock(blocks[1], blocks, dependencyGraph);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> shouldHandleMultipleCallsToClose()
        internal virtual Stream <DynamicTest> ShouldHandleMultipleCallsToClose()
        {
            return(DynamicTest.stream(ArrayFactories(), NumberArrayFactoryName, factory =>
            {
                // GIVEN
                NumberArray <object> array = factory.newIntArray(10, -1);

                // WHEN
                array.Close();

                // THEN should also work
                array.Close();
            }));
        }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void doRace(System.Func<NumberArray,int,Runnable> contestantCreator) throws Throwable
        private void DoRace(System.Func <NumberArray, int, ThreadStart> contestantCreator)
        {
            PageCache pageCache = _pageCacheRule.getPageCache(_fs);
            PagedFile file      = pageCache.Map(_dir.file("file"), pageCache.PageSize(), CREATE, DELETE_ON_CLOSE);
            Race      race      = new Race();

            using (NumberArray array = GetNumberArray(file))
            {
                for (int i = 0; i < CONTESTANTS; i++)
                {
                    race.AddContestant(contestantCreator(array, i));
                }
                race.Go();
            }
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> shouldGetAndSetRandomItems()
        internal virtual Stream <DynamicTest> ShouldGetAndSetRandomItems()
        {
            ThrowingConsumer <NumberArrayTestData> throwingConsumer = data =>
            {
                using (NumberArray array = data.array)
                {
                    IDictionary <int, object> key = new Dictionary <int, object>();
                    Reader reader       = data.reader;
                    object defaultValue = reader.read(array, 0);

                    // WHEN setting random items
                    for (int i = 0; i < INDEXES * 2; i++)
                    {
                        int    index = _random.Next(INDEXES);
                        object value = data.valueGenerator.apply(_random);
                        data.writer.write(i % 2 == 0 ? array : array.at(index), index, value);
                        key.put(index, value);
                    }

                    // THEN they should be read correctly
                    AssertAllValues(key, defaultValue, reader, array);

                    // AND WHEN swapping some
                    for (int i = 0; i < INDEXES / 2; i++)
                    {
                        int fromIndex = _random.Next(INDEXES);
                        int toIndex;
                        do
                        {
                            toIndex = _random.Next(INDEXES);
                        } while (toIndex == fromIndex);
                        object fromValue = reader.read(array, fromIndex);
                        object toValue   = reader.read(array, toIndex);
                        key.put(fromIndex, toValue);
                        key.put(toIndex, fromValue);
                        array.swap(fromIndex, toIndex);
                    }

                    // THEN they should end up in the correct places
                    AssertAllValues(key, defaultValue, reader, array);
                }
            };

            return(DynamicTest.stream(Arrays().GetEnumerator(), data => data.name, throwingConsumer));
        }
Example #6
0
        public override async Task Sort()
        {
            for (int x = NumberArray.Count(); x > 1; x--)
            {
                for (int y = 0; y < NumberArray.Count() - 1; y++)
                {
                    if (NumberArray.ElementAt(y).CompareTo(NumberArray.ElementAt(y + 1)) > 0)
                    {
                        SelectedIndices = new [] { y, y + 1 };
                        NumberArray     = Swap.SwapItem(NumberArray, y, y + 1);
                        TriggerNumbersUpdatedEvent();
                    }
                    await Sleep(UserInterfaceViewModel.Delay).ConfigureAwait(false);
                }
            }

            SelectedIndices = null;
        }
Example #7
0
        public override async Task Sort()
        {
            for (int i = 0; i < NumberArray.Count() - 1; i++)
            {
                int arrayNum = i;
                for (int j = i + 1; j < NumberArray.Count(); j++)
                {
                    SelectedIndices = new[] { j, i };
                    if (NumberArray.ElementAt(j).CompareTo(NumberArray.ElementAt(i)) < 0 && NumberArray.ElementAt(arrayNum).CompareTo(NumberArray.ElementAt(j)) > 0)
                    {
                        arrayNum = j;
                    }
                    await Sleep(UserInterfaceViewModel.Delay).ConfigureAwait(false);
                }
                // Swap
                SelectedIndices = new[] { i, arrayNum };
                NumberArray     = Swap.SwapItem(NumberArray, i, arrayNum);
                TriggerNumbersUpdatedEvent();
            }

            SelectedIndices = null;
        }
Example #8
0
 protected internal override ThreadStart FileRangeRacer(NumberArray array, int contestant)
 {
     return(new FileRangeRacer(this, ( PageCacheIntArray )array, contestant));
 }
        ///<inheritdoc/>
        public void InitTable(ITable subtable)
        {
            Table = subtable;
            commands = new StringArray();
            ids = new NumberArray();
            toCancel = new NumberArray();

            Table.PutValue("Names", commands);
            Table.PutValue("Ids", ids);
            Table.PutValue("Cancel", toCancel);
        }
Example #10
0
 protected internal override ThreadStart WholeFileRacer(NumberArray array, int contestant)
 {
     return(new WholeFileRacer(this, ( ByteArray )array));
 }
 /**
  * An array of numbers that shall be taken pairwise to define a series of
  * points that describes the bounds of an area for which geospatial
  * transformations are valid.
  *
  * @param bounds
  */
 virtual public void SetBounds(NumberArray bounds)
 {
     base.Put(PdfName.BOUNDS, bounds);
 }
 /**
  * An array of numbers that shall be taken pairwise to define points in a 2D
  * unit square. The unit square is mapped to the rectangular bounds of the
  * {@link Viewport}, image XObject, or forms XObject that contains the
  * measure dictionary. This array shall contain the same number of number
  * pairs as the GPTS array; each number pair is the unit square object
  * position corresponding to the geospatial position in the GPTS array.
  *
  * @param pairedpoints
  */
 virtual public void SetLPTS(NumberArray pairedpoints)
 {
     Put(PdfName.LPTS, pairedpoints);
 }
Example #13
0
 /**
  * An array of numbers that shall be taken pairwise, defining points in
  * geographic space as degrees of latitude and longitude. These values shall
  * be based on the geographic coordinate system described in the GCS
  * dictionary.
  *
  * @param pairedpoints
  */
 public void SetGPTS(NumberArray pairedpoints)
 {
     Put(PdfName.GPTS, pairedpoints);
 }
Example #14
0
 private static void AssertAllValues(IDictionary <int, object> key, object defaultValue, Reader reader, NumberArray array)
 {
     for (int index = 0; index < INDEXES; index++)
     {
         object value         = reader.read(index % 2 == 0 ? array : array.at(index), index);
         object expectedValue = key.getOrDefault(index, defaultValue);
         if (value is long[])
         {
             assertArrayEquals(( long[] )expectedValue, ( long[] )value, "index " + index);
         }
         else
         {
             assertEquals(expectedValue, value, "index " + index);
         }
     }
 }
Example #15
0
 protected internal abstract ThreadStart WholeFileRacer(NumberArray array, int contestant);
Example #16
0
        public static Block ParseBlock(XmlNode node, DFG <Block> dfg, ParserInfo parserInfo, bool allowDeclarationBlocks = false, bool canBeScheduled = true)
        {
            string id        = node.GetAttributeValue(Block.ID_FIELD_NAME);
            string blockType = node.GetAttributeValue(Block.TYPE_FIELD_NAME);

            switch (blockType)
            {
            case ArithOP.XML_TYPE_NAME:
                return(ArithOP.Parse(node, dfg, parserInfo, canBeScheduled));

            case Constant.XML_TYPE_NAME:
                return(Constant.Parse(node, parserInfo, canBeScheduled));

            case FluidArray.XML_TYPE_NAME:
                return(FluidArray.Parse(node, dfg, parserInfo));

            case SetArrayFluid.XML_TYPE_NAME:
                return(SetArrayFluid.Parse(node, dfg, parserInfo));

            case Fluid.XML_TYPE_NAME:
                return(Fluid.Parse(node, dfg, parserInfo));

            case InputDeclaration.XML_TYPE_NAME:
                if (!allowDeclarationBlocks)
                {
                    parserInfo.ParseExceptions.Add(new ParseException(id, "Declaration blocks has to be at the top of the program."));
                }
                return(InputDeclaration.Parse(node, parserInfo));

            case OutputDeclaration.XML_TYPE_NAME:
                if (!allowDeclarationBlocks)
                {
                    parserInfo.ParseExceptions.Add(new ParseException(id, "Declaration blocks has to be at the top of the program."));
                }
                return(OutputDeclaration.Parse(node, parserInfo));

            case WasteDeclaration.XML_TYPE_NAME:
                if (!allowDeclarationBlocks)
                {
                    parserInfo.ParseExceptions.Add(new ParseException(id, "Declaration blocks has to be at the top of the program."));
                }
                return(WasteDeclaration.Parse(node, parserInfo));

            case HeaterDeclaration.XML_TYPE_NAME:
                if (!allowDeclarationBlocks)
                {
                    parserInfo.ParseExceptions.Add(new ParseException(id, "Declaration blocks has to be at the top of the program."));
                }
                return(HeaterDeclaration.Parse(node, parserInfo));

            case OutputUsage.XML_TYPE_NAME:
                return(OutputUsage.Parse(node, dfg, parserInfo));

            case WasteUsage.XML_TYPE_NAME:
                return(WasteUsage.Parse(node, dfg, parserInfo));

            case DropletDeclaration.XML_TYPE_NAME:
                return(DropletDeclaration.Parse(node, parserInfo));

            case BoolOP.XML_TYPE_NAME:
                return(BoolOP.Parse(node, dfg, parserInfo, canBeScheduled));

            //case Sensor.XmlTypeName:
            //    return Sensor.Parse(node);
            case GetNumberVariable.XML_TYPE_NAME:
                return(GetNumberVariable.Parse(node, parserInfo, canBeScheduled));

            case SetNumberVariable.XML_TYPE_NAME:
                return(SetNumberVariable.Parse(node, dfg, parserInfo));

            case GetDropletCount.XML_TYPE_NAME:
                return(GetDropletCount.Parser(node, parserInfo, canBeScheduled));

            case GetArrayLength.XML_TYPE_NAME:
                return(GetArrayLength.Parse(node, parserInfo, canBeScheduled));

            case ImportVariable.XML_TYPE_NAME:
                return(ImportVariable.Parse(node, parserInfo, canBeScheduled));

            case NumberArray.XML_TYPE_NAME:
                return(NumberArray.Parse(node, dfg, parserInfo));

            case GetArrayNumber.XML_TYPE_NAME:
                return(GetArrayNumber.Parse(node, dfg, parserInfo, canBeScheduled));

            case SetArrayNumber.XML_TYPE_NAME:
                return(SetArrayNumber.Parse(node, dfg, parserInfo, canBeScheduled));

            case RoundOP.XML_TYPE_NAME:
                return(RoundOP.Parse(node, dfg, parserInfo, canBeScheduled));

            default:
                throw new UnknownBlockException(id);
            }
        }