Does anyone have any code for a custom Dictionary class that preserves the order of items added? I know that the native Xojo Dictionary does not guarantee the order but I am porting some Java code that uses Javas LinkedHashSet which is essentially an ordered Dictionary.
I know that Monkeybread has a class that does this but this is for an open source project that can’t rely on third party license-based plugins so please don’t recommend that.
The problem is the order will change the moment you remove an item. Other than that I did not notify order change, even if the documentation says the order is stable until the dictionary gets changed.
From the documentation about Dictionary.Keys() The order is stable and matches the order returned by the Values method at least until the Dictionary is modified.
I got clarification. Order is not guaranteed for that function as the Dictionary values change, so you will need something like the subclass I mentioned.
send it to me and I can post it on mine if you want ?
however java’s class is a little different than just a xojo dictionary with ordering
unlike xojo’s the java class does NOT replace the entry if you try to add it a second time
it leaves it alone