Inheritance: MonoBehaviour
Example #1
0
            public Buffer(Buffer buffer)
            {
                N            = buffer.N;
                Span         = buffer.Span;
                Heads        = buffer.Heads.ToArray();
                Hashes       = buffer.Hashes.ToArray();
                TagHashes    = buffer.TagHashes.ToArray();
                SuffixHashes = buffer.SuffixHashes.ToArray();
                PrefixHashes = buffer.PrefixHashes.ToArray();
                ShapeHashes  = buffer.ShapeHashes.ToArray();
                Labels       = buffer.Labels.ToArray();
                Moves        = buffer.Moves.ToArray();
                Features     = buffer.Features.ToArray();
                Scores       = buffer.Scores.ToArray();
                ScoresGold   = buffer.Scores.ToArray();
                Stack        = buffer.Stack.Clone();
                CurrentIndex = buffer.CurrentIndex;

                Lefts  = new List <List <int> >();
                Rights = new List <List <int> >();

                for (int i = 0; i < buffer.Lefts.Count; i++)
                {
                    Lefts.Add(buffer.Lefts[i].ToList());
                }

                for (int i = 0; i < buffer.Rights.Count; i++)
                {
                    Rights.Add(buffer.Rights[i].ToList());
                }
            }
Example #2
0
 public CompilationContext(TemplateRootNode templateRootNode)
 {
     this.outputComments   = true;
     this.variables        = new LightList <ParameterExpression>();
     this.statementStacks  = new LightStack <LightList <Expression> >();
     this.hierarchyStack   = new LightStack <ParameterExpression>();
     this.templateRootNode = templateRootNode;
 }
Example #3
0
        public void PopExceptionTest()
        {
            //Arrange
            var stack = new LightStack <string>();

            //Act
            Assert.Throws <InvalidOperationException>(() => stack.Pop());
        }
Example #4
0
        public LightStack <string> Init()
        {
            LightStack <string> stack = new LightStack <string>();

            stack.Push("Pasha");
            stack.Push("Valera");
            stack.Push("Tolik");

            return(stack);
        }
Example #5
0
 private bool IsBetween(int target, LightStack <int> others, int[] gold)
 {
     for (int i = 0; i < others.Length; i++)
     {
         int o = others[i];
         if (gold[o] == target || gold[target] == o)
         {
             return(true);
         }
     }
     return(false);
 }
Example #6
0
        private void OutPutStack_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            Image current = sender as Image;

            if (current != null)
            {
                LightStack <Card> stack = current.DataContext as LightStack <Card>;
                if (stack != null && stack.Count > 0)
                {
                    current.Source = GetBitmap(stack.Peek());
                }
            }
        }
Example #7
0
        public void ReverseTest()
        {
            //Arrange
            var stack = Init();
            LightStack <string> expectedStack = new LightStack <string>();

            expectedStack.Push("Tolik");
            expectedStack.Push("Valera");
            expectedStack.Push("Pasha");

            //Act
            stack.Reverse();

            //Assert
            Assert.AreEqual(expectedStack, stack);
        }
Example #8
0
        private void RefreshMainListPanel()
        {
            var tempStack = new LightStack <Card>();

            if (TempCardStack is null)
            {
                TempCardStack  = new LightStack <Card>();
                TempStackPanel = new LightStack <UIElement>();
            }

            else
            {
                if (MainList != null && MainList.Count > 0)
                {
                    int i        = 0;
                    int upBorder = MainList.Count > countOfCardsInMainStack ? countOfCardsInMainStack : MainList.Count;

                    if (TempCardStack.Count > 0)
                    {
                        TempCardStack.Reverse();

                        while (TempCardStack.Count >= 1)
                        {
                            TempList.Add(TempCardStack.Pop());
                        }

                        TempList.Add(TempCardStack.Peek());
                    }

                    while (i < upBorder)
                    {
                        Card card = MainList.First;
                        TempList.Add(card);
                        positionInMainDeck++;

                        MainList.Remove(card);
                        i++;
                    }

                    TempCardStack.Pop();
                }
            }

            TempCardStack = tempStack;
        }
Example #9
0
 private (int a, int b, int c) GetStackContext(int depth, ref LightStack <int> stack, ref int[] data)
 {
     if (depth > 2)
     {
         return(data[stack[0]], data[stack[1]], data[stack[2]]);
     }
     else if (depth > 1)
     {
         return(data[stack[0]], data[stack[1]], _HashEmpty);
     }
     else if (depth == 1)
     {
         return(data[stack[0]], _HashEmpty, _HashEmpty);
     }
     else
     {
         return(_HashEmpty, _HashEmpty, _HashEmpty);
     }
 }
Example #10
0
        private void NewGame()
        {
            //Deck shuffling, MainList and TempList Reset
            positionInMainDeck = -1;
            MainCardDeck.DeckShuffle();
            MainList     = MainCardDeck.Deck;
            selectedCard = MainList.First;
            TempList     = new LightList <Card>();

            //Output Stacks Reset
            FirstOutPutStack  = new LightStack <Card>();
            SecondOutPutStack = new LightStack <Card>();
            ThirdOutPutStack  = new LightStack <Card>();
            FourthOutPutStack = new LightStack <Card>();

            FirstOutPutStack.Push(new Card(CardSuit.Clovers, CardValue.Ace));
            ThirdOutPutStack.Push(new Card(CardSuit.Diamonds, CardValue.Five));
            TempStackPanel = new LightStack <UIElement>();
            TempCardStack  = new LightStack <Card>();
        }
Example #11
0
        private void RefreshTempStackPanel()
        {
            if (TempCardStack.Count == 0)
            {
                if (TempList != null && TempList.Count > 0 && MainList.Count != 0)
                {
                    var stack    = new LightStack <Card>();
                    int i        = 0;
                    int upBorder = TempList.Count > countOfCardsInMainStack ? countOfCardsInMainStack : TempList.Count;

                    while (i < upBorder)
                    {
                        stack.Push(TempList.Last);
                        TempList.Remove(TempList.Last);
                        i++;
                    }

                    stack.Reverse();
                    TempCardStack = stack;
                }
            }
        }
Example #12
0
        public void CountTest(int expected)
        {
            //Arrange
            int result = 0;
            LightStack <string> stack;

            //Act
            if (expected == 0)
            {
                stack = new LightStack <string>();
            }
            else
            {
                stack = Init();
                if (expected == 4)
                {
                    stack.Push("Natasha");
                }
            }
            result = stack.Count;

            //Assert
            Assert.AreEqual(expected, result);
        }
Example #13
0
            public Buffer(ISpan span, int n_features, int n_moves)
            {
                N             = span.TokensCount + 2;
                Span          = span;
                Heads         = new int[N];
                Hashes        = new int[N];
                TagHashes     = new int[N];
                SuffixHashes  = new int[N];
                PrefixHashes  = new int[N];
                ShapeHashes   = new int[N];
                NumericHashes = new int[N];
                Labels        = new string[N];
                Lefts         = new List <List <int> >();
                Rights        = new List <List <int> >();
                Moves         = new int[n_moves];
                Features      = new int[n_features];
                Scores        = new float[n_moves];
                Stack         = new LightStack <int>();
                for (int i = 0; i < N; i++)
                {
                    if (i == 0)
                    {
                        TagHashes[0]     = _HashRoot;
                        Heads[0]         = -2;
                        Hashes[0]        = TagHashes[0];
                        SuffixHashes[0]  = TagHashes[0];
                        PrefixHashes[0]  = TagHashes[0];
                        ShapeHashes[0]   = TagHashes[0];
                        NumericHashes[0] = TagHashes[0];
                        Labels[0]        = ROOT;
                        Lefts.Add(new List <int>());
                        Rights.Add(new List <int>());
                    }
                    else if (i < N - 1)
                    {
                        var tk = span[i - 1];
                        Heads[i]         = -1;
                        Labels[i]        = tk.DependencyType;
                        TagHashes[i]     = tk.POS.ToString().IgnoreCaseHash32();
                        SuffixHashes[i]  = GetSuffixHash(tk.ValueAsSpan);
                        PrefixHashes[i]  = GetPrefixHash(tk.ValueAsSpan);
                        ShapeHashes[i]   = GetShapeHash(tk.ValueAsSpan, true);
                        NumericHashes[i] = tk.Value.Any(c => char.IsNumber(c)).ToString().IgnoreCaseHash32();
                        Hashes[i]        = tk.IgnoreCaseHash;
                        Lefts.Add(new List <int>());
                        Rights.Add(new List <int>());
                    }
                    else
                    {
                        TagHashes[N - 1]     = _HashEOS;
                        Heads[N - 1]         = -2;
                        Hashes[N - 1]        = TagHashes[N - 1];
                        SuffixHashes[N - 1]  = TagHashes[N - 1];
                        PrefixHashes[N - 1]  = TagHashes[N - 1];
                        ShapeHashes[N - 1]   = TagHashes[N - 1];
                        NumericHashes[N - 1] = TagHashes[N - 1];
                        Labels[N - 1]        = EOS;
                        Lefts.Add(new List <int>());
                        Rights.Add(new List <int>());
                    }
                }

                Lefts.Add(new List <int>());
                Rights.Add(new List <int>());
            }