Yet Another Meat/Item Farm

Veracity

Developer
Staff member
Well, let's see. ASH maps are built on top of Java TreeMaps. Java doc says this:

The order of a map is defined as the order in which the iterators on the map's collection views return their elements. Some map implementations, like the TreeMap class, make specific guarantees as to their order; others, like the HashMap class, do not.

That's hopeful. What does TreeMap say?

This class guarantees that the map will be in ascending key order, sorted according to the natural order for the key's class (see Comparable), or by the comparator provided at creation time, depending on which constructor is used.

OK, fine. I take it back. If all of the keys have the same data type (which will always be the case for ASH maps) - integers in this case - you will get the keys in "natural" order.

Never mind. Feel free to use either "for" or "foreach" as you choose. :)
 

MagiNinjA

New member
Whoa, okay. That's neat to know. And I THOUGHT that there was something like count(). Thanks for using it.

And yeah, once again, the late night strikes! Thus I forgot to stick that return in there...

And thanks for that tip about the map initialization. So sticking it in a function really has no point then? Makes no difference except that it's destroyed after the function finishes? And thus is a performance annoyance? Question marks are cool?
 

macman104

Member
Curious, so now, natural order...for strings, that would be alphabetically right? So, if you have a map indexed by strings, it may not be calling those in the order that you had set up in the script, correct? I realize I could test this with a script, but I thought I'd just ask. However, indexing by number is a safe method of ensuring the order.
 
Top