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/SortedMap.d

    r5064 r5416  
    128128        /*********************************************************************** 
    129129 
    130                 Return the configured allocator 
    131                  
    132         ***********************************************************************/ 
    133  
    134         final Alloc allocator () 
    135         { 
    136                 return heap; 
    137         } 
    138  
    139         /*********************************************************************** 
    140  
    141130                Return a generic iterator for contained elements 
    142131                 
     
    169158                i.node = count ? tree.findFirst(key, cmp, forward) : null; 
    170159                return i; 
     160        } 
     161 
     162        /*********************************************************************** 
     163 
     164                Configure the assigned allocator with the size of each 
     165                allocation block (number of nodes allocated at one time) 
     166                and the number of nodes to pre-populate the cache with. 
     167                 
     168                Time complexity: O(n) 
     169 
     170        ***********************************************************************/ 
     171 
     172        final SortedMap cache (size_t chunk, size_t count=0) 
     173        { 
     174                heap.config (chunk, count); 
     175                return this; 
    171176        } 
    172177 
     
    10761081                // use a chunk allocator, and presize the bucket[] 
    10771082                auto test = new SortedMap!(int, int, Container.reap, Container.Chunk); 
    1078                 test.allocator.config (1000, 500); 
     1083                test.cache (1000, 500_000); 
    10791084                const count = 500_000; 
    10801085                StopWatch w;