guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About hash-table iterators


From: Roland Orre
Subject: About hash-table iterators
Date: Sat, 24 Jan 2004 14:19:18 +0100

The elements of a hash table I consider the handles, not the key and
the value as separate entities, therefore I don't consider the current
iterators hash-map and hash-for-each in guile 1.7 very useful and the
basic iterators I've used over the year, i.e iterating over the handles,
can not be constructed from them. To be able to implement my previous
functionality I had to copy and modify a few routines from hashtab.c to
be able to implement e.g

hash-for-each-handle
hash-map-handles
and from the latter can then e.g hash-table->list be implemented

(define-public (hash-table->list htable)  (hash-map-handles id htable))

and when you don't want to be able to modify the original table you can
use hash-map instead:
(define-public (hash-table-copy->list htable)  (hash-map cons htable))

Is this a general interest? In that case these maybe they should be
considered the basic iterators provided instead of hash-for-each and
hash-map as the latter can be implemented from the other but not vice
versa?

        Best regards
        Roland






reply via email to

[Prev in Thread] Current Thread [Next in Thread]