예제 #1
0
 /// <summary>
 /// Adds a face to the list.
 /// </summary>
 /// <param name="element">The element.</param>
 public void Add(FaceConnector element)
 {
     if (last != null)
     {
         last.Next = element;
     }
     element.Previous = last;
     last             = element;
     if (First == null)
     {
         First = element;
     }
 }
예제 #2
0
        /// <summary>
        /// Get an unused face connector. If none is available, create it.
        /// </summary>
        /// <returns>FaceConnector.</returns>
        public FaceConnector GetConnector()
        {
            if (ConnectorStack == null)
            {
                return(new FaceConnector(Dimension));
            }

            var ret = ConnectorStack;

            ConnectorStack = ConnectorStack.Next;
            ret.Next       = null;
            return(ret);
        }
예제 #3
0
 /// <summary>
 /// Store a face connector in the "embedded" linked list.
 /// </summary>
 /// <param name="connector">The connector.</param>
 public void DepositConnector(FaceConnector connector)
 {
     if (ConnectorStack == null)
     {
         connector.Next = null;
         ConnectorStack = connector;
     }
     else
     {
         connector.Next = ConnectorStack;
         ConnectorStack = connector;
     }
 }
예제 #4
0
        /// <summary>
        /// Connect faces using a connector.
        /// </summary>
        /// <param name="connector">The connector.</param>
        private void ConnectFace(FaceConnector connector)
        {
            var index = connector.HashCode % Constants.ConnectorTableSize;
            var list  = ConnectorTable[index];

            for (var current = list.First; current != null; current = current.Next)
            {
                if (FaceConnector.AreConnectable(connector, current, NumOfDimensions))
                {
                    list.Remove(current);
                    FaceConnector.Connect(current, connector);
                    current.Face   = null;
                    connector.Face = null;
                    ObjectManager.DepositConnector(current);
                    ObjectManager.DepositConnector(connector);
                    return;
                }
            }

            list.Add(connector);
        }
예제 #5
0
        /// <summary>
        /// Removes the element from the list.
        /// </summary>
        /// <param name="connector">The connector.</param>
        public void Remove(FaceConnector connector)
        {
            if (connector.Previous != null)
            {
                connector.Previous.Next = connector.Next;
            }
            else if (/*first == face*/ connector.Previous == null)
            {
                First = connector.Next;
            }

            if (connector.Next != null)
            {
                connector.Next.Previous = connector.Previous;
            }
            else if (/*last == face*/ connector.Next == null)
            {
                last = connector.Previous;
            }

            connector.Next     = null;
            connector.Previous = null;
        }
예제 #6
0
 /// <summary>
 /// Adds the element to the beginning.
 /// </summary>
 /// <param name="connector">The connector.</param>
 private void AddFirst(FaceConnector connector)
 {
     First.Previous = connector;
     connector.Next = First;
     First          = connector;
 }