public void Foo()
        {
            var xs = new TempList <int>(6);

            xs.Add(10);
            xs.Add(20);
            xs.Add(30);
            xs.Add(40);
            xs.Add(50);

            xs.AsSpan().SequenceEqual(new[] { 10, 20, 30, 40, 50 }).Should().BeTrue();

            xs.Dispose();

            var ys = new TempList <int>(3);

            foreach (var item in Enumerable.Range(1, 100))
            {
                ys.Add(item);
            }

            ys.AsSpan().SequenceEqual(Enumerable.Range(1, 100).ToArray()).Should().BeTrue();

            ys.Dispose();
        }
예제 #2
0
 protected void DoLoadConfigAutomatically(ConfigFieldInfo field, int index, TempList <IWork> loaders)
 {
     if (field.LoadAll)
     {
         loaders.Add(new AtomWork(() => ReadAll(index)));
     }
     else if (field.FieldMode == ConfigFieldInfo.Mode.CONST)
     {
         loaders.Add(new AtomWork(() => ReadConst(index, field.ElemType)));
     }
 }
        private void TestNaive()
        {
            //yes, this method of tracking may seem convoluted with the weird temp lists
            //this is to keep GC to a minimum, if not zero
            TempList <MonoBehaviour> stateChanged = null;
            var e = _naiveTrackerTable.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Current.Key == null)
                {
                    if (stateChanged == null)
                    {
                        stateChanged = TempCollection.GetList <MonoBehaviour>();
                    }
                    stateChanged.Add(e.Current.Key);
                }
                else if (e.Current.Value != e.Current.Key.isActiveAndEnabled)
                {
                    if (stateChanged == null)
                    {
                        stateChanged = TempCollection.GetList <MonoBehaviour>();
                    }
                    stateChanged.Add(e.Current.Key);
                }
            }

            if (stateChanged != null)
            {
                for (int i = 0; i < stateChanged.Count; i++)
                {
                    var c = stateChanged[i];
                    if (c == null)
                    {
                        this.PurgeCoroutines(c);
                    }
                    else if (c.isActiveAndEnabled)
                    {
                        _naiveTrackerTable[c] = true;
                        this.DealWithEnable(c);
                    }
                    else
                    {
                        _naiveTrackerTable[c] = false;
                        this.DealWithDisable(c);
                    }
                }
                stateChanged.Dispose();
            }
        }
        /// <summary>
        /// Updates the data for this node and triggers updates for any connected output nodes.
        /// </summary>
        internal override void Update()
        {
            var childFolderArrays = GetInputValues(nameof(_childFolders), new object[] { _childFolders })
                                    .OfType <FolderRef[]>()
                                    .ToArray();

            TempList.Clear();

            for (var i = 0; i < childFolderArrays.Length; i++)
            {
                var childFolderArray = childFolderArrays[i];
                for (var j = 0; j < childFolderArray.Length; j++)
                {
                    var childFolderRef = childFolderArray[j];
                    var newFolderRef   = new FolderRef
                    {
                        FolderName = Path.Combine(COCEditorConstants.ASSET_ROOT, childFolderRef.FolderName),
                        ShouldGenerateCodeToGetPath = childFolderRef.ShouldGenerateCodeToGetPath
                    };
                    TempList.Add(newFolderRef);
                }
            }

            TempList.Sort();

            _outputFolders = TempList.ToArray();

            // Make base call to trigger update on all output ports
            base.Update();
        }
예제 #5
0
        public void setValues(ref T element, int lenght)
        {
            //MessageBox.Show("El largo de la lista recibida es : " + lenght);

            TempList.Add(element);
            //MessageBox.Show("Se agregado en genericList el valor : " + element);
        }
예제 #6
0
        /// <summary>
        /// 添加接货任务
        /// </summary>
        /// <param name="taskid">任务ID </param>
        /// <param name="loadstation">装货区域</param>
        /// <param name="unloadstation">卸货区域</param>
        /// <param name="result">失败原因</param>
        /// <returns></returns>
        public bool AddNDCTask(int taskid, string loadstation, string unloadstation, out string result)
        {
            if (!VCP9412.Instance.IsConnected)
            {
                result = "NDC服务未连接";
                return(false);
            }

            if (!loadStaDic.TryGetValue(loadstation, out string ndcLoadsta))
            {
                result = "装货点未配置";
                return(false);
            }

            if (!unLoadStaDic.TryGetValue(unloadstation, out string ndcUnloadsta))
            {
                result = "卸货点未配置";
                return(false);
            }

            if (Items.Find(c => { return(c._mTask.TASKID == taskid); }) != null)
            {
                result = "找到相同任务ID(" + taskid + ")任务,不能再次添加";
                return(false);
            }

            if (TempList.Find(c => { return(c.TaskID == taskid); }) != null)
            {
                result = "找到相同任务ID(" + taskid + ")任务,不能再次添加";
                return(false);
            }


            TempItem item = new TempItem
            {
                Prio          = "1",
                IKey          = Ikey++,
                TaskID        = taskid,
                LoadSite      = loadstation,
                UnloadSite    = unloadstation,
                NdcLoadSite   = ndcLoadsta,
                NdcUnloadSite = ndcUnloadsta
            };

            TempList.Add(item);
            if (Ikey >= 99)
            {
                Ikey = 1;
            }
            DoStartOrder(item);

            //TaskListUpdate(new NdcTaskModel(item));//更新界面数据

            result = "";
            return(true);
        }
        /// <summary>
        /// Updates the data for this node and triggers updates for any connected output nodes.
        /// </summary>
        internal override void Update()
        {
            var isFolderNameValid = !string.IsNullOrEmpty(_folderRef.FolderName);
            var childFolderArrays = GetInputValues(nameof(_childFolders), new object[0])
                                    .OfType <FolderRef[]>()
                                    .ToArray();
            var length = childFolderArrays.Sum(x => x.Length);

            // If there are not any child folders from other nodes present, return this folder as the
            // array of output folders.
            if (length == 0 && isFolderNameValid)
            {
                _outputFolders = new[]
                {
                    _folderRef
                };
            }
            else if (length > 0 && isFolderNameValid)
            {
                TempList.Clear();

                for (var i = 0; i < childFolderArrays.Length; i++)
                {
                    var childFolderArray = childFolderArrays[i];
                    for (var j = 0; j < childFolderArray.Length; j++)
                    {
                        var childFolderRef = childFolderArray[j];
                        var newFolderRef   = new FolderRef
                        {
                            FolderName = Path.Combine(_folderRef.FolderName, childFolderRef.FolderName),
                            ShouldGenerateCodeToGetPath = childFolderRef.ShouldGenerateCodeToGetPath
                        };

                        TempList.Add(newFolderRef);
                    }
                }

                if (_folderRef.ShouldGenerateCodeToGetPath)
                {
                    TempList.Add(_folderRef);
                }

                _outputFolders = TempList.ToArray();
            }
            else
            {
                _outputFolders = new FolderRef[0];
            }

            // Make base call to trigger update on all output ports
            base.Update();
        }
예제 #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;
        }
예제 #9
0
        //Fill the Window to the Right
        private void MoveElement(object sender, RoutedEventArgs e)
        {
            TempList.Clear();
            VM.ConfigurationList.Clear();
            VM.ParamConfigurationList.Clear();
            //
            foreach (var item in FirstList.SelectedItems)
            {
                TempList.Add(item.ToString());
                VM.ConfigurationList.Add(item.ToString());
            }
            foreach (var item in AlterFirstList.SelectedItems)
            {
                TempList.Add(item.ToString());
                VM.ParamConfigurationList.Add(item.ToString());
            }

            SecondList.ItemsSource = TempList;
        }
예제 #10
0
        private static void Dfs(int currentIndex, int lastNum, int[] nums)
        {
            if (currentIndex == nums.Length)
            {
                if (TempList.Count > 1)
                {
                    Result.Add(new List <int>(TempList));
                }

                return;
            }

            if (nums[currentIndex] >= lastNum)
            {
                TempList.Add(nums[currentIndex]);
                Dfs(currentIndex + 1, nums[currentIndex], nums);
                TempList.RemoveAt(TempList.Count - 1);
            }

            if (nums[currentIndex] != lastNum)
            {
                Dfs(currentIndex + 1, lastNum, nums);
            }
        }
예제 #11
0
 public void setValue(T element)
 {
     //MessageBox.Show("se a añadido  el random : " + element);
     TempList.Add(element);
 }
예제 #12
0
        /// <summary>
        /// 重新读取装货点,卸货点对应NDC实际使用信息
        /// </summary>
        public void DoReadSQL()
        {
            try
            {
                NDCSQLControl control = new NDCSQLControl();
                control.ReadWcsNdcSite(out loadStaDic, out unLoadStaDic);

                control.ReadNDCServerAndIKEY(out IPaddress, out Port, out Ikey);

                if (control.ReadUnFinishTask(out List <WCS_NDC_TASK> list))
                {
                    foreach (var i in list)
                    {
                        if (i.ORDERINDEX == 0)
                        {
                            TempItem item = TempList.Find(c => { return(c.TaskID == i.TASKID || c.IKey == i.IKEY); });
                            if (item == null)
                            {
                                TempList.Add(new TempItem()
                                {
                                    TaskID          = i.TASKID,
                                    IKey            = i.IKEY,
                                    LoadSite        = i.LOADSITE,
                                    UnloadSite      = i.UNLOADSITE,
                                    RedirectSite    = i.REDIRECTSITE,
                                    NdcLoadSite     = i.NDCLOADSITE,
                                    NdcUnloadSite   = i.NDCUNLOADSITE,
                                    NdcRedirectSite = i.NDCREDIRECTSITE
                                });
                            }
                        }
                        else
                        {
                            NDCItem item = Items.Find(c =>
                            {
                                return(c._mTask.IKEY == i.IKEY || c._mTask.TASKID == i.TASKID ||
                                       c._mTask.ORDERINDEX == i.ORDERINDEX);
                            });
                            if (item != null)
                            {
                                item._mTask = i;
                            }
                            else
                            {
                                NDCItem it = new NDCItem()
                                {
                                    _mTask = i
                                };
                                Items.Add(it);
                                CheckCanUpdateTaskList(it);
                            }
                        }
                    }

                    control.DelectUnFinishTaskAfter();
                }
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }