STL-list for another Java list case.

This commit is contained in:
2025-08-06 03:31:51 -04:00
parent 23f82a705c
commit 4a80d1d594
2 changed files with 7 additions and 13 deletions

View File

@ -33,41 +33,35 @@ using namespace lout;
ImageMapsList::ImageMap::ImageMap ()
{
shapesAndLinks = new container::typed::List <ShapeAndLink> (true);
defaultLink = -1;
}
ImageMapsList::ImageMap::~ImageMap ()
{
delete shapesAndLinks;
}
void ImageMapsList::ImageMap::draw (core::View *view,core::style::Style *style,
int x, int y)
{
container::typed::Iterator <ShapeAndLink> it;
for (it = shapesAndLinks->iterator (); it.hasNext (); ) {
ShapeAndLink *shapeAndLink = it.getNext ();
for( auto &shapeAndLink: shapesAndLinks )
{
shapeAndLink->shape->draw(view, style, x, y);
}
}
void ImageMapsList::ImageMap::add (core::Shape *shape, int link) {
ShapeAndLink *shapeAndLink = new ShapeAndLink ();
auto shapeAndLink = std::make_unique< ShapeAndLink >();
shapeAndLink->shape = shape;
shapeAndLink->link = link;
shapesAndLinks->append (shapeAndLink);
shapesAndLinks.push_back( std::move( shapeAndLink ) );
}
int ImageMapsList::ImageMap::link (int x, int y) {
container::typed::Iterator <ShapeAndLink> it;
int link = defaultLink;
for (it = shapesAndLinks->iterator (); it.hasNext (); ) {
ShapeAndLink *shapeAndLink = it.getNext ();
for ( auto &shapeAndLink: shapesAndLinks )
{
if (shapeAndLink->shape->isPointWithin (x, y)) {
link = shapeAndLink->link;
break;

View File

@ -33,7 +33,7 @@ private:
~ShapeAndLink () { if (shape) delete shape; };
};
lout::container::typed::List <ShapeAndLink> *shapesAndLinks;
std::list< std::unique_ptr< ShapeAndLink > > shapesAndLinks;
int defaultLink;
public:
ImageMap ();