home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LANGUAGE / ML / GIML / DICT-SIG.SML < prev    next >
Text File  |  1996-12-09  |  2KB  |  78 lines

  1. (* dict-sig.sml
  2.  *
  3.  * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details.
  4.  *
  5.  * Abstract signature of an applicative-style map/dictionary structure.
  6.  * The weak type variables in this signature are because some implementations
  7.  * (e.g., splay trees) are self adjusting under lookup.
  8.  *
  9.  *)
  10.  
  11. signature DICT =
  12.   sig
  13.  
  14.     structure Key : ORD_KEY
  15.  
  16.     type 'a dict
  17.  
  18.     exception NotFound
  19.  
  20.     val mkDict : unit -> '1a dict
  21.     (* Create a new dict
  22.      *)
  23.  
  24.     val insert : '1a dict * Key.ord_key * '1a -> '1a dict
  25.     (* Insert an item.  
  26.      *)
  27.  
  28.     val find : 'a dict * Key.ord_key -> 'a
  29.     (* Find an item, raising NotFound if not found
  30.          *)
  31.  
  32.     val peek : 'a dict * Key.ord_key -> 'a option
  33.     (* Look for an item, return NONE if the item doesn't exist *)
  34.  
  35.     val remove : '1a dict * Key.ord_key -> '1a dict * '1a
  36.     (* Remove an item, returning new dictionary and value removed.
  37.          * Raise NotFound if not found
  38.      *)
  39.  
  40.     val numItems : 'a dict ->  int
  41.     (* Return the number of items in the table *)
  42.  
  43.     val listItems : 'a dict -> (Key.ord_key * 'a) list
  44.     (* Return a list of the items (and their keys) in the dictionary
  45.          *)
  46.  
  47.     val app : ((Key.ord_key * 'a) -> 'b) -> 'a dict -> unit
  48.     (* Apply a function to the entries of the dictionary
  49.          * in dictionary order.
  50.          *)
  51.  
  52.     val revapp : ((Key.ord_key * 'a) -> 'b) -> 'a dict -> unit
  53.     (* Apply a function to the entries of the dictionary 
  54.          * in reverse dictionary order.
  55.          *)
  56.  
  57.     val fold : (Key.ord_key * 'a * 'b -> 'b) -> 'a dict -> 'b -> 'b
  58.     (* Apply a folding function to the entries of the dictionary
  59.          * in reverse dictionary order.
  60.          *)
  61.  
  62.     val revfold : (Key.ord_key * 'a * 'b -> 'b) -> 'a dict -> 'b -> 'b
  63.     (* Apply a folding function to the entries of the dictionary
  64.          * in dictionary order.
  65.          *)
  66.  
  67.     val map : (Key.ord_key * 'a -> '2b) -> 'a dict -> '2b dict
  68.     (* Create a new table by applying a map function to the
  69.          * name/value pairs in the table.
  70.          *)
  71.  
  72.     val transform : ('a -> '2b) -> 'a dict -> '2b dict
  73.     (* Create a new table by applying a map function to the
  74.          * values in the table.
  75.          *)
  76.  
  77.   end (* DICT *)
  78.