B4J Question How to filter objects ?

FrenchDeveloper

Member
Licensed User
Longtime User
Hello,
I have a set of objects. Each object is an imageview + properties.
This set will grow without limit.
What is the best solution to filter these objects upon one property ?

For example :

Object1 Imageview1 Group1
Object2 Imageview2 Group1
Object3 Imageview3 Group1
Object4 Imageview4 Group2
Object5 Imageview5 Group2

I need to do something on all imageviews of group2.
I could scan each object with a For Each loop but it may be quite long with a lot of objects.
I could copy all properties in a database, a table or in a map and filter the database, the table or the map. Is it possible to filter a table or a map ?
What is the most efficient solution ?
 

Attachments

Last edited:
You could keep an index (as a Map) of the objects that contain each group keyed on the group with a list of objects as the Value.
 
Upvote 0
You could store the info you want using setUserData in each Imageview, then retrieve it with getUserData. It takes a java object so you could store almost anything in there.
You would probably need to use RunMethod to access the field as I don't think B4J exposes it.
 
Upvote 0
You could keep an index (as a Map) of the objects that contain each group keyed on the group with a list of objects as the Value.
Thank you for your answer!
As I am a newbie, I don't imagine how the code would be and how to filter a map upon this index. May be you know a thread where I can find example ?
 
Upvote 0
You could store the info you want using setUserData in each Imageview, then retrieve it with getUserData. It takes a java object so you could store almost anything in there.
You would probably need to use RunMethod to access the field as I don't think B4J exposes it.
Thanks for this advice ! I didn't think it would be possible to store informations in java objects.
How to filter upon one of these informations ?
 
Upvote 0
If you can give me an example of how you are coding the structure, I'll give you an example of indexing it using Map.
 
Upvote 0
If you can give me an example of how you are coding the structure, I'll give you an example of indexing it using Map.

Thank you very much Stevel ! I added a project in the first post.
May be you know where I can find further informations on maps purpose and coding ?
 
Upvote 0
Back
Top