 |
Changeset 5421
- 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
| r5418 |
r5421 |
|
| 72 | 72 | { |
|---|
| 73 | 73 | // bucket types |
|---|
| 74 | | private alias Slink!(V, K) Type; |
|---|
| | 74 | version (HashCache) |
|---|
| | 75 | private alias Slink!(V, K, false, true) Type; |
|---|
| | 76 | else |
|---|
| | 77 | private alias Slink!(V, K) Type; |
|---|
| | 78 | |
|---|
| 75 | 79 | private alias Type *Ref; |
|---|
| 76 | 80 | |
|---|
| … | … | |
| 896 | 900 | { |
|---|
| 897 | 901 | auto n = bucket.next; |
|---|
| 898 | | auto h = Hash (bucket.key, newCap); |
|---|
| | 902 | version (HashCache) |
|---|
| | 903 | auto h = n.cache; |
|---|
| | 904 | else |
|---|
| | 905 | auto h = Hash (bucket.key, newCap); |
|---|
| 899 | 906 | bucket.next = newtab[h]; |
|---|
| 900 | 907 | newtab[h] = bucket; |
|---|
| r4456 |
r5421 |
|
| 32 | 32 | Note that when K is specified, support for keys are enabled. When |
|---|
| 33 | 33 | 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 |
|---|
| 35 | 37 | |
|---|
| 36 | 38 | *******************************************************************************/ |
|---|
| … | … | |
| 38 | 40 | private typedef int KeyDummy; |
|---|
| 39 | 41 | |
|---|
| 40 | | struct Slink (V, K=KeyDummy, bool Identity = false) |
|---|
| | 42 | struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) |
|---|
| 41 | 43 | { |
|---|
| 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 | } |
|---|
| 49 | 55 | |
|---|
| 50 | 56 | /*********************************************************************** |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2012 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic