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

    r5064 r5416  
    133133        /*********************************************************************** 
    134134 
    135                 Return the configured allocator 
    136                  
    137         ***********************************************************************/ 
    138  
    139         final Alloc allocator () 
    140         { 
    141                 return heap; 
    142         } 
    143  
    144         /*********************************************************************** 
    145  
    146135                Return a generic iterator for contained elements 
    147136                 
     
    156145                i.owner = this; 
    157146                return i; 
     147        } 
     148 
     149        /*********************************************************************** 
     150 
     151                Configure the assigned allocator with the size of each 
     152                allocation block (number of nodes allocated at one time) 
     153                and the number of nodes to pre-populate the cache with. 
     154                 
     155                Time complexity: O(n) 
     156 
     157        ***********************************************************************/ 
     158 
     159        final LinkedList cache (size_t chunk, size_t count=0) 
     160        { 
     161                heap.config (chunk, count); 
     162                return this; 
    158163        } 
    159164 
     
    11231128                // use a chunk allocator, and presize the bucket[] 
    11241129                auto test = new LinkedList!(int, Container.reap, Container.Chunk); 
    1125                 test.allocator.config (2000, 500); 
     1130                test.cache (2000, 1_000_000); 
    11261131                const count = 1_000_000; 
    11271132                StopWatch w;