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

    r5064 r5416  
    100100        { 
    101101                reset; 
    102         } 
    103  
    104         /*********************************************************************** 
    105  
    106                 Return the configured allocator 
    107                  
    108         ***********************************************************************/ 
    109  
    110         final Alloc allocator () 
    111         { 
    112                 return heap; 
    113102        } 
    114103 
     
    414403        ***********************************************************************/ 
    415404 
    416         final void buckets (size_t cap) 
     405        final HashSet buckets (size_t cap) 
    417406        { 
    418407                if (cap < Container.defaultInitialBuckets) 
     
    421410                if (cap !is buckets) 
    422411                    resize (cap); 
     412                return this; 
    423413        } 
    424414 
     
    450440                if (table) 
    451441                    checkLoad; 
     442        } 
     443 
     444        /*********************************************************************** 
     445 
     446                Configure the assigned allocator with the size of each 
     447                allocation block (number of nodes allocated at one time) 
     448                and the number of nodes to pre-populate the cache with. 
     449                 
     450                Time complexity: O(n) 
     451 
     452        ***********************************************************************/ 
     453 
     454        final HashSet cache (size_t chunk, size_t count=0) 
     455        { 
     456                heap.config (chunk, count); 
     457                return this; 
    452458        } 
    453459 
     
    841847                // use a chunk allocator, and presize the bucket[] 
    842848                auto test = new HashSet!(int, Container.hash, Container.reap, Container.Chunk); 
    843                 test.allocator.config (1000, 1000); 
     849                test.cache (1000, 1_000_000); 
    844850                test.buckets = 1_500_000; 
    845851                const count = 1_000_000;