5 ms·
I'm probably missing something, but eg awk implements its 'arrays' at least logically with something like a hash set, and indeed hash sets can be great for (say
by DamonHD 9y ago
I'm probably missing something, but eg awk implements its 'arrays' at least logically with something like a hash set, and indeed hash sets can be great for (say) sparse arrays.
Lots of low-level data structures can be implemented in terms of one another, and which makes sense depends on circumstance.
- seanmcdirmid 9y agoLow level doesn't mean simple. In this case, arrays provide a lot of flexibility with manual indexing. They are a low level hammer that can do anything. Sets are much more restricted, they don't have manual indexing, they don't garaunteed iteration ordering without special semantics, they don't do as much as arrays even if they might be implemented with arrays. Then why use an array when you only need a set and an array would be overkill?