I have a class with the following members:
You can create a rectangle with these options.
Now my problem is that I have a list of this class, List<MyClass> .
I need to compare each object of the list with all other objects in such a way that if currentObject.Location(X, Y) falls into the rectangle(X, Y, Width, Height) another object, I need to remove another object from the list.
I implemented it using loops.
But the main problem: performance. My list of minimum lists is 300,000.
Is there any procedure to improve performance for this task on any version of .NET, including LINQ?
`public class RectBase {private int _rectId; private PointF _rectLocation; private SizeF _rectSize;
public RectBase() { _rectId = -911; _rectLocation = new PointF(0, 0); _rectSize = new SizeF(0, 0); } public RectBase(int id, PointF loc, SizeF size) { _rectId = id; _rectLocation = loc; _rectSize = size; } public bool IsIntersected(RectBase otherRectObject) { RectangleF currentRect = new RectangleF(_rectLocation, _rectSize); if (currentRect.Contains(otherRectObject.RectLocation)) return true; else return false; } public int RectId { get { return _rectId; } set { _rectId = value; } } public PointF RectLocation { get { return _rectLocation; } set { _rectLocation = value; } } public SizeF RectSize { get { return _rectSize; } set { _rectSize = value; } } } public class RectProcessor { List<RectBase> _rectList; int maxCount = 300000; public RectProcessor() { _rectList = new List<RectBase>(); FillList(); } private void FillList() {
`
source share