Flameduck my method is a tried and tested one. so your NO reply was indeed wrong. unless of course you want to argue with my C++ prof.
Very well. Your method might be 'tried and tested', but it's still not applicable to this situation.What your professors method does is a waste of resources - your type already has a unique ID - namely its address or handle, so createing any additional ID's are redundant.
Additionally there is no way in your version to ensure that ID's are sequential unless you sort the list every time you add a new element which makes it an even worse solution.
The bottomline is that, contrary to what LISP programers might believe, a list is not a good solution to any given problem. A list is a good solution to a problem that requires sequential access. If you need random access and you're using lists, you're using a wrong collector.
The goal of any algorythm is to get as close to a constant time complexity as possible. Lists have linear time complexity for random access. Arrays and Hashmaps constant, thus they would be better solutions.
I don't believe Max has a built in hashmap does it? If not, it's really a moot point.
Why?