Reputation: 2751
Does ETS set guarantee that internal order of tuples is the same as the order by which they were inserted? For instance: I keep a log by inserting a tuple every second, timestamp is the key. In this example, does set guarantee that tuples are sorted by the key?
I understand that ordered_set would do what I wish, but it has a insert overhead. So if set keeps the insert order, then using set would be much more efficient in my example. So, does it? :-)
Thanks in advance, Nikola
Upvotes: 3
Views: 1072
Reputation: 20926
No, for table type set
there are no guarantees at all of what order the keys are sorted. They are hashed and then the hash value is used to put the elements in a table. The table is occasionally resized and resorted as well so the order will change. So no, you were just lucky.
Upvotes: 5
Reputation: 104090
Even if the ETS set
does fulfill your assumption today, there is no guarantee that it would continue to do so in the future -- especially when there is an ordered_set
that has the exact property you need.
Upvotes: 2