コード例 #1
0
ファイル: ResourceList.cs プロジェクト: mo5h/omeo
 internal void Instantiate(bool optimize)
 {
     if (_list == null)
     {
         ResourceListPredicate oldPredicate = _predicate;
         if (optimize)
         {
             _predicate = _predicate.Optimize(_isLive);
         }
         if (MyPalStorage.TraceOperations && !(_predicate is PlainListPredicate))
         {
             if (!Object.ReferenceEquals(oldPredicate, _predicate))
             {
                 Trace.WriteLine("Predicate before optimization: " + oldPredicate.ToString());
             }
             Trace.WriteLine("Instantiating list " + _predicate.ToString());
         }
         bool predicateSortedById = false;
         _list = _predicate.GetMatchingResources(out predicateSortedById);
         if (_isLive && !_handlersAttached)
         {
             SetLive();
         }
         if (_lastComparer != null)
         {
             DoSort(_lastComparer, true);
         }
         else if (predicateSortedById)
         {
             _lastComparer = new ResourceComparer(this, new SortSettings(ResourceProps.Id, true), false);
         }
     }
 }
コード例 #2
0
ファイル: ResourceList.cs プロジェクト: mo5h/omeo
        private void DoSort(ResourceComparer comparer, bool instantiating)
        {
            lock (this)
            {
                _lastComparer = comparer;
                if (_list == null || _list.Count == 0)
                {
                    return;
                }

                if (_lastComparer.IsIdSort())
                {
                    _list.Sort();
                }
                else if (_explicitSort)
                {
                    // If we are sorting a list which has already been sorted,
                    // use RBTree-based stable sort
                    StableSort();
                }
                else
                {
                    QuickSort(instantiating);
                }

                _explicitSort = true;
            }
        }