I have a program that creates custom objects from text documents that contain certain pieces of data. Each object has its own Boolean tags that correspond to different states the object could be under based upon the data in the text file. A sample of the object would look something like this.
When the program is finished there will be hundreds of different datastate Booleans possible for each object, each with unique names that correspond to different things I want to track about each object (aka, the Booleans will not have sequential names). A separate function runs that will read each object.textfile and activate the proper datastate Booleans to true. What I would like to be able to do is write a search function that would look something like the following pseudo code:
SomeSearchFunction(Object [] someobjectarray, Parameter adatastate){
//This code takes in an array of objects and searches for all objects where
//the Parameter variable is true. The Parameter value can be any of the
//Boolean tags. This program would return an Object [] where all the chosen
//Parameter Boolean tags were true.
}
In short, I’m a little stumped on how best to accomplish this. Any ideas, examples, or tutorials that might speak to this would be very helpful.
When you have a central hashmap with all booleans and all objects use this hashmap, then the search can for loop over it and compare a search pattern with the objects
On 2nd thought, given we’re simply checking whether an object contains some tag, we can just use a StringList instead: Processing.org/reference/StringList.html
But I believe this one cannot be used in Processing directly due to lack of lambdas. Still it can be used when developing on top of Processing directly in Java, like I do in this project: https://github.com/morisil/processing-shaders/
Thanks for the suggestions everyone. I am still testing out my code but so far it looks like the first suggestion by GoToLoop works the way I want it to. I can add all the Boolean tags that an object might have into a HashMap by String name, then type that String name in as the parameter in the search function, if the parameter has a stored value in the HashMap then I can find out if that Boolean is true or false and run a for loop to cover each object.
That seems like it is doing exactly what I need. I haven’t tried any of the other methods but I will to see how each method functions.