2 scm-hash.cc -- implement Scheme_hash_table
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "scm-hash.hh"
15 Scheme_hash_table::Scheme_hash_table ()
22 Scheme_hash_table::operator =(Scheme_hash_table
const & src
)
24 Scm_stl_map::operator = (src
);
26 // we do not copy the self_scm_ field!
30 Scheme_hash_table::do_smobify_self ()
36 Scheme_hash_table::mark_smob (SCM s
)
39 can't typecheck naively, since GC bit lives in CAR of S
42 Scheme_hash_table
*me
= SMOB_TO_TYPE(Scheme_hash_table
,s
);
44 for (Scm_stl_map::const_iterator i
= me
->begin (); i
!= me
->end(); i
++)
46 scm_gc_mark ((*i
).first
);
47 scm_gc_mark ((*i
).second
);
53 Scheme_hash_table::Scheme_hash_table (Scheme_hash_table
const &src
)
61 Scheme_hash_table::print_smob (SCM s
, SCM p
, scm_print_state
*)
63 assert (SMOB_IS_TYPE_B (Scheme_hash_table
, s
));
65 sprintf (str
, "#<Scheme_hash_table 0x%0x ", s
);
67 Scheme_hash_table
*me
= SMOB_TO_TYPE(Scheme_hash_table
,s
);
68 for (Scm_stl_map::const_iterator i
= me
->begin (); i
!= me
->end(); i
++)
70 scm_display ((*i
).first
, p
);
72 scm_display ((*i
).second
, p
);
80 Scheme_hash_table::try_retrieve (SCM k
, SCM
*v
)
82 Scm_stl_map ::const_iterator
i (find (k
));
83 bool found
= i
!= end ();
90 Scheme_hash_table::elem_b (SCM k
) const
92 Scm_stl_map::const_iterator
i (find (k
));
97 Scheme_hash_table::set (SCM k
, SCM v
)
104 Scheme_hash_table::get (SCM k
)const
106 return (*(Scheme_hash_table
*)this)[k
];
110 Scheme_hash_table::~Scheme_hash_table( )
116 Scheme_hash_table::to_alist () const
119 for (Scm_stl_map ::const_iterator i
= begin (); i
!= end(); i
++)
120 l
= gh_cons (gh_cons ((*i
).first
, (*i
).second
), l
);
125 #include "ly-smobs.icc"
126 IMPLEMENT_UNSMOB(Scheme_hash_table
,scheme_hash
);
127 IMPLEMENT_SMOBS(Scheme_hash_table
);