This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme style auto-resizing hashtable (fwd)


On Tue, 3 Nov 1998, Tel wrote:

> > 	dictionary-add!
> > 	dictionary-lookup
> > 	dictionary-remove!
> > 	dictionary->pairs
> > 	dictionary->keys
> > 	dictionary->values
> 
>    index-insert!     -- adds an item or replaces existing item
>    index-find        -- returns an item or #f if not found
>    index-remove!     -- removes an item or do nothing if not found
>    index-list        -- return a sorted list of items between given bounds
>    index-length      -- count items
> 
>    table-insert!          -- Add an ID/attribute/value tuple
>    table-get-data         -- like find but inconsistently named
>    table-remove!          -- delete tuples
>    table-list-ids         -- return a sorted list of matching ids
>    table-list-attributes  -- return a sorted list of attributes
>    table-length           -- number of tuples stored
>    table-biggest          -- largest ID number stored
>    table-get-next         -- lookup the next item after given value
>    table-get-prev         -- lookup the previous item before given value
> 
> For what it's worth, I like the sound of ``index-lookup'' and ``table-lookup''
> so I'll switch those over. Since the -> is used extensively in guile for
> symbols that convert between types, I'll change over to these names:
> 
>    index-lookup
>    table-lookup
>    table-next
>    table-prev
>    index->list
>    table->ids
>    table->attributes
> 
> That should be reasonably standard... I might take a while to change these
> over.
> 
> I don't like inconsistent behaviour being defined for a similar sounding
> name.
> 
> > 	dictionary-map
> > 	dictionary-foreach
> > 	dictionary-copy!

any suggestions?

> 
> I've been meaning to get around to writing something equivalent to these.
> 
> > 	dictionary-clear!
> 
> My table-remove! and index-remove! have optional arguments, if you
> only supply one argument (the table) they delete everything, as you
> supply more args they get more selective. I'm still wondering if this
> use for optional arguments is clever or just confusing.

sounds a bit dangerous, consider

(apply dictionary-clear! lst)

the user means for "lst" to be (my-dictionary #t) or whatever, but
mistakenly has it set to just (my-dictionary) 

> > 	dictionary-update!
> 
> what does this do?

Here are much better names (I was going to make its behavior conditional
on the type of the argument... not a good idea, I think): 

dictionary-add-dictionary!  (err, dictionary-insert-dictionary!)
dictionary-add-alist!       (..., dictionary-insert-alist!)

here's a new list of dictionary procedures

constructors:

        make-dictionary
        make-dictionaryv
        make-dictionaryq

behavior modifiers:

        dictionary-enable! 
        dictionary-disable!
        dictionary-change-type!

the big three basic operations:

        dictionary-insert!
        dictionary-lookup
        dictionary-remove!

iterators and friends:

        dictionary-map                <-> ???
        dictionary-foreach            <-> ???
	dictionary-make-iterator  -- perhaps add an "auto-grow"
				  -- option to be toggled off until
				  -- iterator is finished
	call-with-dictionary-iterator

dictionary to whatever conversions:

	dictionary->alist           -- was dictionary->items
	dictionary->keys  
	dictionary->values

whatever to dictionary "conversions":

	dictionary-insert-alist!
	dictionary-consume-alist!  -- delete alist while
				   -- inserting pairs (to conserve memory)
	dictionary-insert-dictionary!
	dictionary-consume-dictionary! -- delete buckets while 
                                       -- inserting entries

statistics:
	
	dictionary-stats
	dictionary-more-stats

the rest:

        dictionary-clear!
        dictionary-copy!