示例#1
0
            public T1 this[int index]
            {
                get
                {
                    RBOrderedMultiTree <T1> multiTree = mTree as RBOrderedMultiTree <T1>;
                    if (multiTree == null)
                    {
                        return(default(T1));
                    }

                    RBOrderedTreeNode <T1> node = multiTree.GetByOrder(index);
                    if (node != null)
                    {
                        return(node.Key);
                    }

                    return(default(T1));
                }
                set
                {
                    RBOrderedMultiTree <T1> multiTree = mTree as RBOrderedMultiTree <T1>;
                    if (multiTree == null)
                    {
                        return;
                    }

                    RBOrderedTreeNode <T1> node = multiTree.GetByOrder(index);
                    if (node != null)
                    {
                        multiTree.Remove(node);
                        multiTree.Add(value);
                    }
                }
            }
示例#2
0
 public T1 this[int index]
 {
     get
     {
         RBOrderedMultiTree <T1> mTree = this.mTree as RBOrderedMultiTree <T1>;
         if (mTree == null)
         {
             return(default(T1));
         }
         RBOrderedTreeNode <T1> byOrder = mTree.GetByOrder(index);
         if (byOrder != null)
         {
             return(byOrder.Key);
         }
         return(default(T1));
     }
     set
     {
         RBOrderedMultiTree <T1> mTree = this.mTree as RBOrderedMultiTree <T1>;
         if (mTree == null)
         {
             return;
         }
         RBOrderedTreeNode <T1> byOrder = mTree.GetByOrder(index);
         if (byOrder == null)
         {
             return;
         }
         mTree.Remove(byOrder);
         mTree.Add(value);
     }
 }
示例#3
0
            public int IndexOf(T1 item)
            {
                RBOrderedMultiTree <T1> multiTree = mTree as RBOrderedMultiTree <T1>;

                if (multiTree == null)
                {
                    return(-1);
                }

                RBOrderedTreeNode <T1> node = multiTree.Find(item);

                return(multiTree.GetOrder(node));
            }
示例#4
0
            public void RemoveAt(int index)
            {
                RBOrderedMultiTree <T1> mTree = this.mTree as RBOrderedMultiTree <T1>;

                if (mTree == null)
                {
                    return;
                }
                RBOrderedTreeNode <T1> byOrder = mTree.GetByOrder(index);

                if (byOrder == null)
                {
                    return;
                }
                mTree.Delete((RBTreeNodeBase <T1, RBOrderedNodeParam>)byOrder);
            }
示例#5
0
            public int IndexOf(T1 item)
            {
                RBOrderedMultiTree <T1> mTree = this.mTree as RBOrderedMultiTree <T1>;

                if (mTree == null)
                {
                    return(-1);
                }
                RBOrderedTreeNode <T1> aItem = mTree.Find(item);

                if (aItem == null)
                {
                    return(-1);
                }
                return(mTree.GetOrder(aItem));
            }
示例#6
0
            public void RemoveAt(int index)
            {
                RBOrderedMultiTree <T1> multiTree = mTree as RBOrderedMultiTree <T1>;

                if (multiTree == null)
                {
                    return;
                }

                RBOrderedTreeNode <T1> node = multiTree.GetByOrder(index);

                if (node != null)
                {
                    multiTree.Delete(node);
                }
            }
示例#7
0
        protected override void Perform()
        {
            if (this.version == this.CollectionView.Version)
            {
                return;
            }
            RBOrderedMultiTree <T> orderedMultiTree = (RBOrderedMultiTree <T>)null;
            IEnumerable <T>        objs             = this.CollectionView.IsIncrementalFiltering ? (IEnumerable <T>) this.items : this.source;

            if (this.CollectionView.CanSort && this.CollectionView.SortDescriptors.Count != 0)
            {
                orderedMultiTree = new RBOrderedMultiTree <T>(this.CollectionView.Comparer);
            }
            else
            {
                this.items = (IList <T>) new List <T>(64);
            }
            if (this.CollectionView.CanFilter && this.CollectionView.Filter != null)
            {
                if (orderedMultiTree != null)
                {
                    foreach (T aKey in objs)
                    {
                        if (this.CollectionView.PassesFilter(aKey))
                        {
                            orderedMultiTree.Add(aKey);
                        }
                    }
                    this.items = orderedMultiTree.Collection;
                }
                else
                {
                    this.items.Clear();
                    foreach (T obj in objs)
                    {
                        if (this.CollectionView.PassesFilter(obj))
                        {
                            this.items.Add(obj);
                        }
                    }
                }
                this.version = this.CollectionView.Version;
            }
            else if (this.CollectionView.CanSort && this.CollectionView.SortDescriptors.Count != 0)
            {
                if (orderedMultiTree != null)
                {
                    foreach (T aKey in objs)
                    {
                        orderedMultiTree.Add(aKey);
                    }
                    this.items = orderedMultiTree.Collection;
                }
                else
                {
                    this.items.Clear();
                    foreach (T obj in objs)
                    {
                        this.items.Add(obj);
                    }
                }
                this.version = this.CollectionView.Version;
            }
            else
            {
                this.InitializeItems();
                this.version = this.CollectionView.Version;
            }
        }
示例#8
0
        protected virtual void PerformWithBinaryTree()
        {
            if (this.version == this.CollectionView.Version)
            {
                return;
            }
            RBOrderedMultiTree <T> orderedMultiTree = (RBOrderedMultiTree <T>)null;
            IEnumerable <T>        e = this.CollectionView.IsIncrementalFiltering ? (IEnumerable <T>) this.items : this.source;

            if (this.CollectionView.CanSort && this.CollectionView.SortDescriptors.Count != 0)
            {
                orderedMultiTree = new RBOrderedMultiTree <T>(this.CollectionView.Comparer);
            }
            else
            {
                this.items = (IList <T>) new List <T>(64);
            }
            if (this.CollectionView.CanFilter && this.CollectionView.Filter != null)
            {
                if (orderedMultiTree != null)
                {
                    foreach (T filteredItem in this.GetFilteredItems(e))
                    {
                        orderedMultiTree.Add(filteredItem);
                    }
                    this.items = orderedMultiTree.Collection;
                }
                else
                {
                    this.items.Clear();
                    foreach (T filteredItem in this.GetFilteredItems(e))
                    {
                        this.items.Add(filteredItem);
                    }
                }
                this.version = this.CollectionView.Version;
            }
            else if (this.CollectionView.CanSort && this.CollectionView.SortDescriptors.Count != 0)
            {
                if (orderedMultiTree != null)
                {
                    foreach (T aKey in e)
                    {
                        orderedMultiTree.Add(aKey);
                    }
                    this.items = orderedMultiTree.Collection;
                }
                else
                {
                    this.items.Clear();
                    foreach (T obj in e)
                    {
                        this.items.Add(obj);
                    }
                }
                this.version = this.CollectionView.Version;
            }
            else
            {
                this.InitializeItems();
                this.version = this.CollectionView.Version;
            }
        }