map of maps
Subject: map of maps
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-10-31 14:32:13 GMT
Hi,
I have a question regarding the implementation of maps. Let's say I have
a map of maps, in which the first mapis keyed by strings, and the
second map is keyed by ints. Let's say I have 10 strings, and 1 million
ints per string. Let's say I want to add an element.
let add k1 k2 elem t =
let m2 =
try Fst.find k1 t
with Not_found -> Snd.empty
in
let m2 = Snd.add k2 elem m2 in
Fst.add k1 m2 t
where Fst is the first map and Snd is the second map, k1 is the key of
the first, and k2 is the key of the second.
Every time I do this, am I completely rewriting the int map, which is 1
million ints keys plus their elements? If not, how does the compiler get
around this, and are there still any significant performance issues?
Will using Hashtbls circumvent this problem?
Thanks,
David
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___

RSS Feed