|
[Sponsors] |
January 4, 2007, 05:15 |
I'm looking for a means of mai
|
#1 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
I'm looking for a means of maintaining a hash in the inserted (created) order.
Here is an example of the (undesirable) behaviour that I'm currently seeing: HashTable<label> hash; for (label i=0; i < 10; i++) { hash.insert(word("key" + Foam::name(i)), i); } Info << hash << endl; --- Results in 10 ( key8 8 key9 9 key6 6 key7 7 key4 4 key5 5 key2 2 key3 3 key0 0 key1 1 ) At the moment, the first, rather inelegant, workaround I came up is to combine a HashTable<label> (for the keyword lookup) and a Map<entry> (to maintain the insertion order). The net effect is something like HashTable<entry,word,hash<label> >, but a bit clumsier. Any hints about a better way? Thanks, /mark |
|
January 4, 2007, 05:17 |
Note: the email version of the
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Note: the email version of the posting is terribly mangled. Please see the web version
|
|
|
|