External Interfaces |
Description of Function pb_remove
1. Look For the Key in the Phone Book
Arguments passed to pb_remove
are the Properties
object pb_htable
and the name
key for the entry to remove. The pb_remove
function calls containsKey
on pb_htable
with the name
key, on which support function pb_keyfilter
is called to change spaces to underscores. If name is not in the phone book, disp
displays a message and the function returns.
function pb_remove(pb_htable,name) if ~pb_htable.containsKey(pb_keyfilter(name)) disp(sprintf('The name %s is not in the phone book',name)) return end;
2. Ask for Confirmation and If Given, Remove the Key
If the key is in the hash table, pb_remove
asks for user confirmation. If the user confirms the removal by entering y
, pb_remove
calls remove
on pb_htable
with the (filtered) name
key, and displays a message that the entry has been removed. If the user enters n
, the removal is not performed and disp
displays a message that the removal has not been performed.
r = input(sprintf('Remove entry %s (y/n)? ',name), 's'); if r == 'y' pb_htable.remove(pb_keyfilter(name)); disp(sprintf('%s has been removed from the phone book',name)) else disp(sprintf('%s has not been removed',name)) end;
Description of Function pb_add | Description of Function pb_change |
© 1994-2005 The MathWorks, Inc.