[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looping through an array with FOR EACH
[Thread Prev] | [Thread Next]
- Subject: Re: Looping through an array with FOR EACH
- From: Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
- Date: Sat, 17 Jan 2026 01:01:39 +0100
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Le 17/01/2026 à 00:00, Brian G a écrit :
On 1/16/26 14:15, Jussi Lahtinen wrote:Long time ago Benoit said about collections: "The hash table elements are linked both by hash slot and insertion order. But I don't guarantee that this non-official feature won't be removed.". So, For Each is not guaranteed to iterate the elements in the insertion order.JussiYes this is very obvious, as it is probably a hash table, or tree
Everything is in the source code. :-) 'Collection' is a hash table, whose nodes have three links:- A link to the next element having the same hash, or NULL if it is the last one.
- A link to the element previously inserted or NULL if it is the first. - A link to the next inserted element, or NULL if it is the last one.The Collection itself maintain a link to the first inserted element, and slots for the different possible hashing values.
So having elements ordered in a collection requires two pointers (16 bytes on 64 bites) for each element.
This might be a problem if you need a collection with millions of elements and don't need to maintain the order of insertion.
But even if I said "order is not guaranted", I don't think this feature will be removed.
And if really an hash table with no order to save memory is required, I will add an "HashTable" class for that, to keep backward-compatibility.
So the "not guaranted" guaranty may become "guaranted" in the future. Regards, -- Benoît Minisini.
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Brian G <brian@xxxxxxxxxxxxxxxx> |
| Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | BB <adamnt42@xxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Brian G <brian@xxxxxxxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Brian G <brian@xxxxxxxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Brian G <brian@xxxxxxxxxxxxxxxx> |