Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact
Show
Ignore:
Timestamp:
03/23/10 02:19:11 (2 years ago)
Author:
kris
Message:

added support for retaining the key hash-value (via a -version=HashCache? in the interim)

Files:

Legend:

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

    r4456 r5421  
    3232        Note that when K is specified, support for keys are enabled. When 
    3333        Identity is stipulated as 'true', those keys are compared using an 
    34         identity-comparison instead of equality (using 'is'). 
     34        identity-comparison instead of equality (using 'is'). Similarly, if 
     35        HashCache is set true, an additional attribute is create in order to 
     36        retain the hash of K 
    3537 
    3638*******************************************************************************/ 
     
    3840private typedef int KeyDummy; 
    3941 
    40 struct Slink (V, K=KeyDummy, bool Identity = false
     42struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false
    4143{ 
    42         alias Slink!(V, K)      Type; 
    43         alias Type              *Ref; 
    44         alias Compare!(V)       Comparator; 
    45  
    46  
    47         Ref     next;           // pointer to next 
    48         V       value;          // element value 
     44        alias Slink!(V, K, Identity, HashCache) Type; 
     45        alias Type                              *Ref; 
     46        alias Compare!(V)                       Comparator; 
     47 
     48        Ref             next;           // pointer to next 
     49        V               value;          // element value 
     50 
     51        static if (HashCache == true) 
     52        { 
     53        hash_t       cache;             // retain hash value? 
     54        } 
    4955                 
    5056        /***********************************************************************