internal Enumerator(FixedSizeStack <T> stack)
 {
     _stack          = stack;
     _version        = _stack._version;
     _index          = -2;
     _currentElement = default(T);
 }
        public NavigationManager()
        {
            _backwardStack = new FixedSizeStack<NavigationLocation>(100);
            _forwardStack = new FixedSizeStack<NavigationLocation>(100);

            _updateTimer = new Timer();
            _updateTimer.Interval = 200;
            _updateTimer.Tick += new EventHandler(timer_Tick);
            _updateTimer.Start();
        }
        public void FixedSizeStack_CanPeek()
        {
            FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
            stack.Push(1);
            Assert.AreEqual(1, stack.Count);

            int peeked = stack.Peek();
            Assert.AreEqual(1, peeked);
            Assert.AreEqual(1, stack.Count);
        }
        public void FixedSizeStack_CanPop()
        {
            FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
            stack.Push(1);
            Assert.AreEqual(1, stack.Count);

            int popped = stack.Pop();
            Assert.AreEqual(1, popped);
            Assert.AreEqual(0, stack.Count);
        }
Beispiel #5
0
        public BehaviorIterator(BehaviorTree tree, int levelOffset)
        {
            this.tree   = tree;
            LevelOffset = levelOffset;

            var maxTraversalLen = this.tree.Height + 1;

            traversal           = new FixedSizeStack <int>(maxTraversalLen);
            requestedTraversals = new Queue <int>(maxTraversalLen);
        }
        public CompletionPopupView()
        {
            InitializeComponent();
            events = new FixedSizeStack<IPopupEvent>(15);

            CompletionItems.PreviewKeyDown += (sender, args) => Publish(new CancellableKeyEvent(args, EventSource.Popup));
            CompletionItems.ItemClicked += (sender, args) => Publish(new ItemClickedEvent(args.Arg2, (ICompletionItem)args.Arg1));

            Opened += (obj, args) => Publish(new PopupStateChanged(PopupState.Open));
            Closed += (obj, args) => Publish(new PopupStateChanged(PopupState.Closed));
            DataContextChanged += OnDataContextChanged;
        }
        public void FixedSizeStack_CanClear()
        {
            FixedSizeStack<int> stack = new FixedSizeStack<int>(10);
            for (int i = 0; i < 10; i++)
            {
                stack.Push(i);
            }
            Assert.AreEqual(10, stack.Count);

            stack.Clear();
            Assert.AreEqual(0, stack.Count);
        }
Beispiel #8
0
        public CompletionPopupView()
        {
            InitializeComponent();
            events = new FixedSizeStack <IPopupEvent>(15);

            CompletionItems.PreviewKeyDown += (sender, args) => Publish(new CancellableKeyEvent(args, EventSource.Popup));
            CompletionItems.ItemClicked    += (sender, args) => Publish(new ItemClickedEvent(args.Arg2, (ICompletionItem)args.Arg1));

            Opened             += (obj, args) => Publish(new PopupStateChanged(PopupState.Open));
            Closed             += (obj, args) => Publish(new PopupStateChanged(PopupState.Closed));
            DataContextChanged += OnDataContextChanged;
        }
Beispiel #9
0
        public ModeMovingFilter(int frames, int width, int height)
        {
            modeFrameCount = frames;
            modeQueue      = new FixedSizeStack(modeFrameCount);

            frecuencies = new Frec[width * height];

            //inicializamos
            for (int i = 0; i < width * height; i++)
            {
                frecuencies[i] = new Frec(modeFrameCount);
            }
        }
Beispiel #10
0
 public void FixedSizeStack_PeekThrowsWhenEmpty()
 {
     FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
     try
     {
         stack.Peek();
         Assert.Fail("Peeking did not throw an exception when the stack was empty.");
     }
     catch (InvalidOperationException)
     {
         // expected
     }
 }
Beispiel #11
0
        public void AddTest()
        {
            FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
            stack.Add(1, score: 0);
            Assert.IsTrue(stack.Elements.Contains(1));

            stack.Add(2, score: 100);
            Assert.IsTrue(stack.Elements.Contains(1));
            Assert.IsFalse(stack.Elements.Contains(2));

            stack.Add(3, score: -1);
            Assert.IsTrue(stack.Elements.Contains(3));
            Assert.IsFalse(stack.Elements.Contains(1));
        }
Beispiel #12
0
 public void FixedSizeStack_EnforcesSizeLimit()
 {
     FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
     stack.Push(1);
     try
     {
         stack.Push(2);
         Assert.Fail("We were able to insert two items into a stack that is of fixed size 1.");
     }
     catch (InvalidOperationException)
     {
         // expected
     }
 }
Beispiel #13
0
        public KanjiViewModel()
            : base(NavigationPageEnum.Kanji)
        {
            NavigationActor.Instance.KanjiVm = this;

            _kanjiFilter  = new KanjiFilter();
            KanjiFilterVm = new KanjiFilterViewModel(_kanjiFilter);
            KanjiListVm   = new KanjiListViewModel(_kanjiFilter);

            KanjiFilterVm.FilterChanged += OnFilterChanged;
            KanjiListVm.KanjiSelected   += OnKanjiSelected;

            ClearSelectedKanjiCommand = new RelayCommand(OnClearSelectedKanji);
            ClearFilterCommand        = new RelayCommand(OnClearFilter);
            NavigateBackCommand       = new RelayCommand(OnNavigateBack);

            _navigationHistory = new FixedSizeStack <KanjiNavigationEntry>(
                MaxNavigationHistorySize);
        }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolitaireBoard"/> class.
 /// </summary>
 public SolitaireBoard()
 {
     _mainDeck = new Deck();
     _mainDeck.Shuffle();
     _gamePiles = new FixedSizeStack<Card>[7];
     for (int i = 0; i < _gamePiles.Length; i++)
     {
         var pile = new FixedSizeStack<Card>(i + 1);
         for (int j = 0; j < i + 1; j++)
         {
             pile.Push(_mainDeck.Draw());
         }
         _gamePiles[i] = pile;
     }
     _suitPiles = new FixedSizeStack<Card>[4];
     for (int i = 0; i < _suitPiles.Length; i++)
     {
         _suitPiles[i] = new FixedSizeStack<Card>(13);
     }
 }
Beispiel #15
0
        private void ManageSubCaptures(OCaptureTable <TValue> table, SequenceHandler <TValue> handler,
                                       FixedSizeStack <FSAState> states, FixedSizeStack <int> piStack)
        {
            var stack = _captureStack;

            stack.Clear();

            for (int i = 0; i < piStack.Count; i++)
            {
                var s  = states[i];
                int id = piStack[i] - 1;
                if (id >= 0)
                {
                    var cond = _transitionMatrix[s.StateId][id].Condition;
                    if (cond.IsSystemPredicate)
                    {
                        var sys = (SystemPredicateEdge <TValue>)cond;
                        if (sys.IsCapture)
                        {
                            var right = new CaptureEdge
                            {
                                Index     = s.CurrentIndex,
                                CaptureId = sys.CaptureId
                            };
                            if (stack.Count > 0 && stack.Peek().CaptureId == right.CaptureId)
                            {
                                var left = stack.Pop();
                                table.Add(
                                    left.CaptureId,
                                    new OCapture <TValue>(handler, new Range(left.Index, right.Index - left.Index)));
                            }
                            else
                            {
                                stack.Push(right);
                            }
                        }
                    }
                }
            }
        }
Beispiel #16
0
 public PlayerUndo()
 {
     undoStack = new FixedSizeStack <IUndoAction>(BlueprintTweaksPlugin.undoMaxHistory.Value);
     redoStack = new FixedSizeStack <IUndoAction>(BlueprintTweaksPlugin.undoMaxHistory.Value);
 }
Beispiel #17
0
 public void FixedSizeStack_CanPush()
 {
     FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
     stack.Push(1);
     Assert.AreEqual(1, stack.Count);
 }
Beispiel #18
0
 private StateManager()
 {
     //LoadState(DEFAULT_STATE_FILE);
     stateStack = new FixedSizeStack <string>(DEFAULT_STATE_STACK_SIZE);
 }
Beispiel #19
0
        FixedSizeStack<Image> NearestNeighbor(Image image)
        {
            FixedSizeStack<Image> fss = new FixedSizeStack<Image>(_NbNeighbor);
            int startIndex = 0;
            int endIndex = _nbImage;

            if (SemiRandomNeighbor)
            {
                int nbElementsToTest = _NbNeighbor * NeighborScaleFactor;
                Random gen = new Random();
                startIndex = gen.Next(0, _nbImage - nbElementsToTest);
                endIndex = startIndex + nbElementsToTest;
            }

            double norme = image.Norm;
            int nbImageBlockedByTriangleSpeedUp = 0;

            for (int i = startIndex; i < endIndex; i++)
            {
                if (UseTriangleSpeedUp && fss.IsFull)
                {
                    double d = Math.Abs(_normes[i] - norme);
                    // This image can never be added to stack
                    if (d > fss.MaxScore)
                    {
                        nbImageBlockedByTriangleSpeedUp++;
                        continue;
                    }
                }

                double dist = image.Distance(_images[i]);
                fss.Add(_images[i], dist);
            }
            if (Debug) Console.WriteLine("nbImageBlockedByTriangleSpeedUp:" + nbImageBlockedByTriangleSpeedUp);

            return fss;
        }
        public KanjiViewModel()
            : base(NavigationPageEnum.Kanji)
        {
            NavigationActor.Instance.KanjiVm = this;

            _kanjiFilter = new KanjiFilter();
            KanjiFilterVm = new KanjiFilterViewModel(_kanjiFilter);
            KanjiListVm = new KanjiListViewModel(_kanjiFilter);

            KanjiFilterVm.FilterChanged += OnFilterChanged;
            KanjiListVm.KanjiSelected += OnKanjiSelected;

            ClearSelectedKanjiCommand = new RelayCommand(OnClearSelectedKanji);
            ClearFilterCommand = new RelayCommand(OnClearFilter);
            NavigateBackCommand = new RelayCommand(OnNavigateBack);

            _navigationHistory = new FixedSizeStack<KanjiNavigationEntry>(
                MaxNavigationHistorySize);
        }
Beispiel #21
0
 static BTUndoSystem()
 {
     m_undoStack = new FixedSizeStack <BTUndoState>(MAX_UNDO_STACK_SIZE);
     m_redoStack = new FixedSizeStack <BTUndoState>(MAX_UNDO_STACK_SIZE);
 }
Beispiel #22
0
 public void Setup()
 {
     _stack = new FixedSizeStack <string>(5);
 }