Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Predicate to search a List<List<Point>>?

Status
Not open for further replies.

Insider1984

Technical User
Feb 15, 2002
132
US
Hi there. I have a List<List<Point>> (maybe this is a bad idea but i need 2D array with speed).

The problem I have is search for points inside this array. I know that I should use a Predicate but the only example I found (interestingly enough) is from Microsoft and they are using an Array[] Points.

I think I'm very close but need help with one peice of code inside the predicate, the P coming in.... is that the point from my list of lists or is it the point that I'm trying to find on?

How do I do the comparison? Also see if their is a way below to make this easier.....

Code:
                            Nullable<Point> temppoint = new Nullable<Point>(new Nullable<Point>(new Point(pointX - 1, pointY)));
                            int temp = tempDefectBlob[tempDefectBlob.Count].Find(temppoint,PointMatch);



//later in the code:
    private static bool PointMatch(Point p)
    {
        if (p.X == ?????? %% p.Y == ???????)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

Should I use a List<Point[]> instead?

=====================
Insider
4 year 'on the fly' programmer
C, C++, C#, MFC, Basic, Java ASP.NET
 
Well, for the outer most List, item type is List<Point>, so you need to search for List, not Point. I presume that the code should look something like this:

Code:
List<List<Point>>   points;

foreach (List<Point> list in points)
{
    if (list.find(test_point))
        return true;
}
return false;

------------------
When you do it, do it right.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top