Persistent data structure: Difference between revisions

Content deleted Content added
Line 416:
Point points[] = { Point(1,1), Point(3,1), Point(2,2), Point(4,2), Point(2,4),Point(4,4),Point(2,5),Point(4,5),Point(3,7),Point(5,7) };
Point q(3,3);
Segment segment1segments[]={Segment(points[0],points[1]),Segment(points[2],points[3]),Segment(points[4],points[5]),Segment(points[6],points[7])};
Segment segment2(points[2],points[3]);
Segment segment3(points[4],points[5]);
Segment segment4(points[6],points[7]);
int stripSize=(sizeof points / sizeof points[0]);
int segmentSize=(sizeof segments / sizeof segments[0]);
Strip *strips=new Strip [stripSize];
 
Line 465 ⟶ 463:
int indexOfStrip= getIndexOfStrip(strips,q.x,stripSize);
Point target=strips[indexOfStrip].copy->findSmallestLargerOrEqualYCoordinatePoint(strips[indexOfStrip].copy,q.y);
cout<<"Segment above the query point has starting point:";
cout<<if((target;.x==-1 && target.y==-1))
{
cout<<"There is no segment above the query point q";
}
else
{
cout<<"Segment above the query point q has starting point:";
cout<<target;
for(int i=0;i<segmentSize;i++)
{
if(segments[i].startPoint.x==target.x && segments[i].startPoint.y==target.y)
{
cout<<"and end point:";
cout<<segments[i].endPoint;
break;
}
}
}
delete[] strips;
return 0;
}
 
</syntaxhighlight>