Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3669

Show
Ignore:
Timestamp:
06/23/08 03:24:26 (3 months ago)
Author:
kris
Message:

isolated simple remove/replace methods

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/util/container/HashSet.d

    r3600 r3669  
    231231        ***********************************************************************/ 
    232232 
    233         final uint remove (V element, bool all=false) 
     233        final uint remove (V element, bool all) 
     234        { 
     235                return remove(element) ? 1 : 0; 
     236        } 
     237 
     238        /*********************************************************************** 
     239 
     240                Remove the provided element. Returns true if found, false 
     241                otherwise 
     242                 
     243                Time complexity: O(1) average; O(n) worst 
     244 
     245        ***********************************************************************/ 
     246 
     247        final bool remove (V element) 
    234248        { 
    235249                if (count) 
     
    253267                            else 
    254268                               trail.next = n; 
    255                             return 1
     269                            return true
    256270                            }  
    257271                         else 
     
    262276                         } 
    263277                   } 
    264                 return 0
     278                return false
    265279        } 
    266280 
     
    273287        ***********************************************************************/ 
    274288 
    275         final uint replace (V oldElement, V newElement, bool all=false) 
     289        final uint replace (V oldElement, V newElement, bool all) 
     290        { 
     291                return replace (oldElement, newElement) ? 1 : 0; 
     292        } 
     293 
     294        /*********************************************************************** 
     295 
     296                Replace the first instance of oldElement with newElement. 
     297                Returns true if oldElement was found and replaced, false 
     298                otherwise. 
     299                 
     300        ***********************************************************************/ 
     301 
     302        final bool replace (V oldElement, V newElement) 
    276303        { 
    277304 
     
    281308                      remove (oldElement); 
    282309                      add (newElement); 
    283                       return 1
     310                      return true
    284311                      } 
    285                 return 0
     312                return false
    286313        } 
    287314 
     
    324351        ************************************************************************/ 
    325352 
    326         public uint remove (IContainer!(V) e, bool all=false
     353        public uint remove (IContainer!(V) e
    327354        { 
    328355                uint c; 
    329356                foreach (value; e) 
    330                          if (remove (value, all)) 
     357                         if (remove (value)) 
    331358                             ++c; 
    332359                return c;