Beispiel #1
0
        public void Remove(TreeData <T> data)
        {
            if (!data.mAxisAlignedRectangle.Intersects(mBoundary))
            {
                return;
            }

            var index = mTreeData.FindIndex(ele => ele.mT.Equals(data.mT));

            if (index >= 0 && index < mTreeData.Count)
            {
                mTreeData.RemoveAt(index);
                return;
            }

            if (!mIsSubDivided)
            {
                return;
            }

            mNorthWest.Remove(data);
            mNorthEast.Remove(data);
            mSouthWest.Remove(data);
            mSouthEast.Remove(data);

            if (mNorthWest.mTreeData.Count == 0 && !mNorthWest.mIsSubDivided &&
                mNorthEast.mTreeData.Count == 0 && !mNorthEast.mIsSubDivided &&
                mSouthWest.mTreeData.Count == 0 && !mSouthWest.mIsSubDivided &&
                mSouthEast.mTreeData.Count == 0 && !mSouthEast.mIsSubDivided)
            {
                mNorthWest    = null;
                mNorthEast    = null;
                mSouthWest    = null;
                mSouthEast    = null;
                mIsSubDivided = false;
            }
        }
Beispiel #2
0
        public void Remove(T t, Rectangle rectangle)
        {
            var data = new TreeData <T>(t, rectangle);

            mRootNode.Remove(data);
        }
Beispiel #3
0
        public bool Insert(T t, Rectangle rectangle)
        {
            var data = new TreeData <T>(t, rectangle);

            return(mRootNode.Insert(data));
        }