示例#1
0
        internal PropertySiblingEnumerator(LinkedListNode node) : base(node)
        {
            // Initialiwation of the left and right bounds of the collection parsed by this enumerator
            // Since this enumerator parses only sibling properties, left and right bounds are the bounds
            // of the linked list pointed to by this enumerator

            mLeftBound = new PropertySiblingEnumerator();
            mLeftBound.Node = Node.Owner.LeftBound;

            mRightBound = new PropertySiblingEnumerator();
            mRightBound.Node = Node.Owner.RightBound;

            mLeftBound.LeftBoundInternal = LeftBound;
            mLeftBound.RightBoundInternal = RightBound;
            mRightBound.LeftBoundInternal = LeftBound;
            mRightBound.RightBoundInternal = RightBound;
        }
示例#2
0
        internal PropertyVisibleSiblingEnumerator(LinkedListNode node) : base(node)
        {
            // We may point to an invisible property so we must find for the first visible one after it

            // First we must ensure that all our ancestors are expanded. If not, this enumerator
            // will initially point to RightBound
            PropertyEnumerator pEnumerator = new PropertyDeepEnumerator(Node);
            while (pEnumerator.HasParent)
            {
                pEnumerator.MoveParent();
                if ((pEnumerator.Property.Expanded == false) || (pEnumerator.Property.Visible == false))
                {
                    Node = RightBound.Node;
                    break;
                }
            }

            while ((this != RightBound) && (Property.Visible == false))
                MoveNext();
        }
示例#3
0
 internal PropertyDeepEnumerator(LinkedListNode node) : base(node)
 {
     // Initialization of the left and right bounds of the collection parsed by this enumerator
     CalcLeftAndRightBounds();
 }
示例#4
0
        internal PropertyVisibleDeepEnumerator(LinkedListNode node) : base(node)
        {
            // We may point to an invisible property so we must find for the first visible one after it

            // First we must ensure that all our ancestors are expanded. If not, this enumerator
            // will initially point to the upper enumerator that is collapsed
            PropertyEnumerator pEnumerator = new PropertyDeepEnumerator(Node);
            while (pEnumerator.HasParent)
            {
                pEnumerator.MoveParent();
                if ((pEnumerator.Property.Expanded == false) || (pEnumerator.Property.Visible == false))
                    Node = pEnumerator.Node;
            }

            if (this != LeftBound)
            {
                // Once we are on an expanded part of the tree we go to a visible property
                while ((this != RightBound) && (Property.Visible == false))
                    MoveNext();
            }
        }
示例#5
0
        public void Sort(IComparer comparer)
        {
            int limit = Count - 1;
            while (limit > 0)
            {
                LinkedListNode node = _head;
                for (int i = 0; i < Count - 1; i++)
                {
                    if (comparer.Compare(node.Value, node.Next.Value) > 0)
                    {
                        if (node == _head)
                            _head = node.Next;
                        else if (node.Next == _tail)
                            _tail = node;

                        LinkNode(node.Previous, node.Next);
                        LinkedListNode lastNode = node.Next.Next;
                        LinkNode(node.Next, node);
                        LinkNode(node, lastNode);
                    }
                    else
                        node = node.Next;
                }

                limit--;
            }
        }
示例#6
0
 internal PropertyEnumerator(LinkedListNode node)
 {
     _node = node;
 }
示例#7
0
        public void Clear()
        {
            // Reinitialize the bounds of this list
            LinkNode(_leftBound, _rightBound);

            _count = 0;
            _head = null;;
            _tail = null;
        }
示例#8
0
        public void Remove(LinkedListNode node)
        {
            LinkedListNode prev = node.Previous;
            LinkedListNode next = node.Next;

            if (node == _head && node == _tail)
                _head = _tail = null;
            else if (node == _head)
                _head = next;
            else if (node == _tail)
                _tail = prev;

            LinkNode(prev, next);

            _count--;
        }
示例#9
0
        public LinkedListNode InsertAfter(LinkedListNode after, object value)
        {
            if (after == _tail)
                return Append(value);
            else if (after == _leftBound)
                return Prepend(value);
            else
            {
                LinkedListNode node = new LinkedListNode(this, value);
                LinkedListNode next = after.Next;

                LinkNode(after, node);
                LinkNode(node, next);

                _count++;

                return node;
            }
        }
示例#10
0
        public LinkedListNode InsertBefore(LinkedListNode before, object value)
        {
            if (before == _head)
                return Prepend(value);
            else if (before == _rightBound)
                return Append(value);
            else
            {
                LinkedListNode node = new LinkedListNode(this, value);
                LinkedListNode prev = before.Previous;

                LinkNode(prev, node);
                LinkNode(node, before);

                _count++;

                return node;
            }
        }
示例#11
0
        public LinkedListNode Prepend(object value)
        {
            LinkedListNode node = new LinkedListNode(this, value);

            if (_tail == null)
            {
                _tail = node;
                LinkNode(_leftBound, node);
                LinkNode(node, _rightBound);
            }
            else
            {
                LinkNode(_leftBound, node);
                LinkNode(node, _head);
            }

            _head = node;
            _count++;

            return node;
        }
示例#12
0
 private static void LinkNode(LinkedListNode node1, LinkedListNode node2)
 {
     node1.Next = node2;
     node2.Previous = node1;
 }
示例#13
0
        public LinkedList(LinkedListNode parentNode, int depth)
        {
            _depth = depth;
            _parent = parentNode;

            // Initialize the bounds of this list
            _leftBound = new LinkedListNode(this, null);
            _rightBound = new LinkedListNode(this, null);
            LinkNode(_leftBound, _rightBound);
        }