Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2878

Appending to Dispatch[] tables

From Szabolcs Horvát <szhorvat@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Appending to Dispatch[] tables
Date 2011-06-01 10:57 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <is55u5$d25$1@smc.vnet.net> (permalink)

Show all headers | View raw


Is there an efficient way to add more rules to a Dispatch[] table?  I 
see that it contains a HashTable object, but the format of HashTable is 
not documented.

Adding new DownValues for a symbol is much more efficient than 
extracting the rule-list from a Dispatch, adding to it, and re-building 
the Dispatch table, however Dispatch[] is more convenient for certain 
applications than a symbol with DownValues (save for the limitation of 
adding new values).

Is there any inherent reason why it's not possible to efficiently add to 
a Dispatch, possibly by modifying the HashTable object contained within? 
  One reason I could imagine is that this type of modification would 
involve appending to lists (both the rule list and the HashTable within 
Dispatch), and appending is quadratically slow (because of the need to 
re-allocate the list).

Do Dispatch[] and symbols w DownValues use the same code in the background?

Any pointers on the topic are most welcome!

  -- Szabolcs

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Appending to Dispatch[] tables Szabolcs Horvát <szhorvat@gmail.com> - 2011-06-01 10:57 +0000

csiph-web