util/dsymtable.cc
changeset 721 5dc33058e041
parent 596 4efb11e44065
child 972 bc90dd4bbf4f
equal deleted inserted replaced
720:f637ac331a68 721:5dc33058e041
    32 
    32 
    33 
    33 
    34 #include <iostream>
    34 #include <iostream>
    35 #include "symtable.hh"
    35 #include "symtable.hh"
    36 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
    36 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
    37 
       
    38 
       
    39 
       
    40 
    37 
    41 
    38 
    42 
    39 
    43  /* clear all entries... */
    40  /* clear all entries... */
    44 template<typename value_type, value_type null_value>
    41 template<typename value_type, value_type null_value>
    86 }
    83 }
    87 #endif
    84 #endif
    88 
    85 
    89 
    86 
    90 
    87 
    91 /* Determine how many entries are associated to key identifier_str */ 
       
    92 /* returns:
       
    93  *         0: if no entry is found
       
    94  *         1: if 1 entry is found
       
    95  *         2: if more than 1 entry is found 
       
    96  */
       
    97 template<typename value_type, value_type null_value>
       
    98 int dsymtable_c<value_type, null_value>::multiplicity(const char *identifier_str) {
       
    99   iterator lower = _base.lower_bound(identifier_str);
       
   100   if (lower == _base.end()) return 0;
       
   101 
       
   102   iterator upper = _base.upper_bound(identifier_str);
       
   103   iterator second = lower;
       
   104   second++;
       
   105   
       
   106   if (second == upper) return 1;
       
   107   
       
   108   return 2;
       
   109 }
       
   110 
       
   111 
    88 
   112 /* returns null_value if not found! */
    89 /* returns null_value if not found! */
   113 template<typename value_type, value_type null_value>
    90 template<typename value_type, value_type null_value>
   114 value_type dsymtable_c<value_type, null_value>::find_value(const char *identifier_str) {
    91 value_type dsymtable_c<value_type, null_value>::find_value(const char *identifier_str) {
   115   iterator i = _base.find(identifier_str);
    92   iterator i = _base.find(identifier_str);