Hi, I made a Double Linked List data structure. But I am in a snag for a certain part of my program. I have a player class, with name,age,exp. I can add players to my list and stuff ok.
My problem is this:
I want to search my list based on one of those fields. For instance, I want to search each players exp field, and see if it matches a certain number. But, I am stumped how I can do this. My custom list is a tenplate class. So, How can I iterate through the list and pick out only the players that have exp at say 100?
I call the search using list.Search(some params) from my main method. I don't want to use a "predicate" class if that is possible.
You've asked the exact same thing yesterday. Look, you can either use a predicate class, a predicate function, or embed the logic of how to search for a player in the list class. The third one is obviously flawed.
Other than that you could also create a search object of player and try to get away with a simple equality comparison, but in that case you could not search for example only for exp, you would have to search for an exact match.