imnplimenting object and retreiving list, filtering, invoking methods. low level system code, [on hold]

I’m thinking about system level code, and am wondering about how to implement objects whose fields can be accessed.

So if we have an object named task, with a members such as tid and kill. we could get at the tid by calling task->tid. No what if we had to deal with many task objects, such as we’d want to kill all tasks with a tid > 100.

How could this be implemented properly? A naive implementation might loop through each object and check the tid, but this already isn’t enough. The object can be changed or modified in any way, to make this robust and performant. As long as we identify where any new methods are, how the result is accessed, it would help me understand how this might be approached.