Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact
Show
Ignore:
Timestamp:
03/21/10 14:15:40 (2 years ago)
Author:
kris
Message:

made the default allocator faster, and hid the implementation from the containers. Use the new cache() method instead for configuring how containers pre-allocate.

Files:

Legend:

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

    r5131 r5416  
    131131        /*********************************************************************** 
    132132 
    133                 Return the configured allocator 
    134                  
    135         ***********************************************************************/ 
    136  
    137         final Alloc allocator () 
    138         { 
    139                 return heap; 
    140         } 
    141  
    142         /*********************************************************************** 
    143  
    144133                Return a generic iterator for contained elements 
    145134                 
     
    157146                i.index = 0; 
    158147                return i; 
     148        } 
     149 
     150        /*********************************************************************** 
     151 
     152                Configure the assigned allocator with the size of each 
     153                allocation block (number of nodes allocated at one time) 
     154                and the number of nodes to pre-populate the cache with. 
     155                 
     156                Time complexity: O(n) 
     157 
     158        ***********************************************************************/ 
     159 
     160        final CircularList cache (size_t chunk, size_t count=0) 
     161        { 
     162                heap.config (chunk, count); 
     163                return this; 
    159164        } 
    160165 
     
    11871192                // use a chunk allocator, and presize the bucket[] 
    11881193                auto test = new CircularList!(uint, Container.reap, Container.Chunk); 
    1189                 test.allocator.config (1000, 1000); 
     1194                test.cache (1000, 1_000_000); 
    11901195                const count = 1_000_000; 
    11911196                StopWatch w;