Would it be simpler, as effective, and almost as efficient to use the default?
P.S. Is this the correct way to specific an alternate hash function?
2) Is this the correct way to add new records to the table and update existing records?
(define update-IPv4-counters (lambda (addr direction proto tokens)
(let ((IP-record (hash-table-ref/default IPv4-table addr #f))) (cond ((not (vector? IP-record)) ; addr is not in the table, this is a new entry (hash-table-set! IPv4-table addr
(update-IP-record (make-IP-record) direction proto tokens))) (else ; addr is in the table, increment packets and add bytes (hash-table-set! IPv4-table addr (update-IP-record IP-record direction proto tokens)))))))
Note that an IP record is a seven elements vector (i.e. created with make-vector).
If I understand SRFI-69 correctly, hash-table-set! will replace a record with the same key. Is this correct? There cannot be duplicate keys, right?
This code displays two records with the same key and different data. This has happened more than once. I have kept the output files.
If I call hash-table-set! with the same address as another record but in a different format (say a vector instead of a u8vector), would it choke or would it just create a new record without complaining? This would look like duplicate keys but they would be different.
I assume that hash-table-for-each will present each key / record pair once and do so in some arbitrary order.
Can I assume that dump-IPv4-record, when it calls IPv4-address->string, will choke on a key which is not a u8vector?
I am looking for the mistake I made which is producing the illusion of a duplicate key in the hash table. I believe that confirming my assumptions is a good starting point.
I hope this sort of question is not abusing the list members.