Ejemplo n.º 1
0
        public override void Create_list_and_add_values_after_clear()
        {
            using var sut =
                      new ListPool <int>(3)
                  {
                      s_fixture.Create <int>(), s_fixture.Create <int>(), s_fixture.Create <int>()
                  };

            sut.Clear();

            Assert.Empty(sut);
        }
        public static void GetFiles(Regex re, string path, ICollection <FileHandle> result)
        {
            Initialize();
            ListPool <string, IFileDirectory> .PooledList pooledList = ListPool <string, IFileDirectory> .Allocate();

            foreach (IFileDirectory file_source in file_sources)
            {
                pooledList.Clear();
                file_source.GetFiles(re, path, pooledList);
                foreach (string item in pooledList)
                {
                    result.Add(new FileHandle
                    {
                        full_path = item,
                        source    = file_source
                    });
                }
            }
            pooledList.Recycle();
        }
Ejemplo n.º 3
0
 public void ListPool()
 {
     _listPool.Clear();
 }
    private void AddChoreEntry(Chore chore)
    {
        HierarchyReferences choreEntry = GetChoreEntry(GameUtil.GetChoreName(chore, null), chore.choreType, choreGroup.GetReference <RectTransform>("EntriesContainer"));
        FetchChore          fetchChore = chore as FetchChore;

        ListPool <Chore.Precondition.Context, BuildingChoresPanel> .PooledList pooledList = ListPool <Chore.Precondition.Context, BuildingChoresPanel> .Allocate();

        foreach (MinionIdentity item in Components.LiveMinionIdentities.Items)
        {
            pooledList.Clear();
            ChoreConsumer component = item.GetComponent <ChoreConsumer>();
            Chore.Precondition.Context         context = default(Chore.Precondition.Context);
            ChoreConsumer.PreconditionSnapshot lastPreconditionSnapshot = component.GetLastPreconditionSnapshot();
            if (lastPreconditionSnapshot.doFailedContextsNeedSorting)
            {
                lastPreconditionSnapshot.failedContexts.Sort();
                lastPreconditionSnapshot.doFailedContextsNeedSorting = false;
            }
            pooledList.AddRange(lastPreconditionSnapshot.failedContexts);
            pooledList.AddRange(lastPreconditionSnapshot.succeededContexts);
            int num  = -1;
            int num2 = 0;
            for (int num3 = pooledList.Count - 1; num3 >= 0; num3--)
            {
                Chore.Precondition.Context context2 = pooledList[num3];
                if ((UnityEngine.Object)context2.chore.driver != (UnityEngine.Object)null)
                {
                    Chore.Precondition.Context context3 = pooledList[num3];
                    if ((UnityEngine.Object)context3.chore.driver != (UnityEngine.Object)component.choreDriver)
                    {
                        continue;
                    }
                }
                bool flag = pooledList[num3].IsPotentialSuccess();
                if (flag)
                {
                    num2++;
                }
                Chore.Precondition.Context context4       = pooledList[num3];
                FetchAreaChore             fetchAreaChore = context4.chore as FetchAreaChore;
                Chore.Precondition.Context context5       = pooledList[num3];
                if (context5.chore == chore || (fetchChore != null && fetchAreaChore != null && fetchAreaChore.smi.SameDestination(fetchChore)))
                {
                    num     = ((!flag) ? 2147483647 : num2);
                    context = pooledList[num3];
                    break;
                }
            }
            if (num >= 0)
            {
                DupeEntryDatas.Add(new DupeEntryData
                {
                    consumer         = component,
                    context          = context,
                    personalPriority = component.GetPersonalPriority(chore.choreType),
                    rank             = num
                });
            }
        }
        pooledList.Recycle();
        DupeEntryDatas.Sort();
        foreach (DupeEntryData dupeEntryData in DupeEntryDatas)
        {
            GetDupeEntry(dupeEntryData, choreEntry.GetReference <RectTransform>("DupeContainer"));
        }
        DupeEntryDatas.Clear();
    }