SGI-STL abbreviated (eight) - hashed associative containers (hash, hash_set, hash_map, hash_multiset, hash_multimap)

stl_hash_fun.h: 
    hash: Template function object class type, generally as hash_set, hash_map, hash_multiset, the default hash function hash_multimap container, now offers more specialized versions, and heavy-duty implement operator (), the parameter types are char, unsigned char , char * , int, etc. 
    built into integer data type version; except const char * char * and use __stl_hash_string hash value is calculated, the remainder is returned directly value parameter value as a hash value; Ha The return value is a Greek type size_t; 
    __stl_hash_string: traversing each string element, traversing a cumulative hash value is calculated, calculated as H = 0 ; H = . 5 * + H * S, S * to corresponding elements traversal string, h is the the final hash value, the type unsigned Long ; 
    other examples of hash template implemented, such as the basic_string <_CharT, _Traits, _Alloc> , crope, wrope template function or a hash of the user-defined objects achieved; 
    
stl_hashtable.h: 
    _Hashtable_node: template class hash table node;  
    data members:
        _M_next: hash pointer points to the next node in the table; 
        _M_val: Saves the current value (hash value) of the hash table of the node; 
    _Hashtable_iterator / _Hashtable_const_iterator: hash table iterator class template, template parameters _Val, _Key, _HashFcn, _ExtractKey , _EqualKey, _Alloc are value types, the type of the key, a hash function, key type extraction, equal key type, the type of memory allocation; 
    internal re-declared type of the front forward_iterator_tag iterator type, and the value_type, pointers, and other references; 
    data member : 
        _M_cur: current iterator pointer pointing to the node where the vessel; 
        _M_ht: container object pointer iterator iterator; 
    member function: 
        _Hashtable_iterator constructor initializes _M_cur, _M_ht members; 
        furthermore overloaded operator * and operator-> Solutions fetching pointer references and internal node returns the current value _M_val _M_cur their addresses; 
        overloaded operator ==, operator =! direct comparison _M_cur pointer address; 
        the overloaded operator ++, operator ++ ( int ) implemented prior to the iteration; 
        iterative way: get the next _M_next _M_cur of a node if the next node is not directly returned empty or not empty while loop to find a barrel after the tank (bucket) where the elements of the current node, and current settings iterator points to the first node of the new barrel; (because no node portion of the barrel may, 
        under the need to traverse to find a node where to find the next time a node is not empty bucket); 
    Hashtable: Hashtable template class, as hash_set, hash_map , hash_multiset, the bottom of the container to achieve the hash hash_multimap; _Hashtable_iterator iterator same template parameter template parameter; 
        aid function or global variable: 
            __stl_prime_list: number of the array of pre-populated list of the tub, as pre-set __stl_num_primes 28, i.e. 28 group, number __stl_prime_list inner tub is substantially in accordance with the value of twice the growth mode, at least dispensing barrel 53, up to the tub can be assigned 4294967291; 
            __stl_next_prime: returns the number of receiving at least a pre-specified value n buckets allocated bucket list corresponding __stl_prime_list number; 
        hash table template class heavy declares key_type, value_type, pointers, references, etc. that Of a conventional type, in addition Hasher (hash function object), key_equal (equal comparison function object key), and other types iterator; 
        data member: 
            _M_hash: a hash function object; 
            _M_equals: key equality comparison function object; 
            _M_get_key: Extraction key function object;
            _M_buckets: Vector <_Hashtable_node <Val> *> tub type container object, mainly for holding the head node list points to the node at the same HASH_KEY (i.e., having the same key value with the various elements of the next bucket), somewhat similar to the structure deque structure underlying internal layout, but the 
            node data of certain bucket hash table may be empty and not necessarily continuous, but is deque (pointer within the scope of the iterator section) continuous addition at each node in the hash table buckets not necessarily contiguous buffers, each buffer is not necessarily continuous bucket, the deque node and the node buffers are continuous, 
            each node is not necessarily continuous); 
            _M_num_elements: the actual number of elements stored in the node vessel; 
            _M_node_allocator: node allocator object 
        member function: 
            hash_funct: Object returns _M_hash; 
            key_eq: Object returns _M_equals; 
            get_allocator: returns the current node memory allocator object _M_node_allocator; 
            constructors: providing initialization bucket number n, the hash function HF, equal comparison function eql, ext key extraction function and a memory assignment in an initial Data member of the respective hash table; internal call _M_initialize_buckets actual initialization operation performed tub; 
            _M_initialize_buckets: initialization barrel, internal call _M_next_size get the actual number of barrels at least assignable and adjustment _ M_buckets container size and initialized _M_num_elemen ts is 0; 
            _M_next_size: obtaining an actual number of barrels may be at least allocated internal call __stl_next_prime acquired; 
            copy constructor: data members by a respective source container initialization, in addition also called copy _M_copy_from data to the same container under the respective hash table buckets; 
            _M_copy_from: internal container readjust _M_buckets bucket size; inner loop through all nodes to each bucket and the container at each of the current bucket, which is specifically operable to: create each bucket call _M_new_node by way of the node and the first interpolation node is added to the current configuration of the single list corresponding to the container barrel. 
            _M_new_node: _M_get_node internal call request buffer space and calls a node designation of the node value of obj construct configuration; 
            _M_get_node / _M_put_node: application / release of a buffer memory size of the node; 
            replicated copies of function: first call clear clear the current container element, and initialized by the source data corresponding members, in addition to call at each node element tub _M_copy_from copy source container; 
            destructor: internal call clear clear all the elements of the current container; 
            clear: Clear all the elements of this container, which traverse the respective inner barrels and barrels each node in the list and calls _M_delete_node destroy the node, in addition to the container emptying the tub (tub simply modified container element is 0), _ M_num_elements adjusted to 0;
            _M_delete_node: internal call the destructor destroy destroy target node, the node thereafter release call _M_put_node memory buffer; 
            size: Returns the number of the current container element (return _M_num_elements); 
            MAX_SIZE: Returns the current maximum capacity of the container may contain elements (return size_type ( - . 1  )); 
            empty: this container is empty;
            the swap: exchange two hash tables container element, simply exchanging the internal hash function hash table objects _M_hash, equal comparison function object _M_equals, key extraction function object _M_get_key, barrel container _M_buckets, and a container the number of elements _M_num_elements; 
            the begin: hash table returns an iterator first vessel (in fact return to the first iteration of the object node is not empty bucket configuration of the first node appears); 
            End: returns a hash table container iterator tail (can be returned by the iterator object empty node configuration); 
            BUCKET_COUNT: returns the current bucket container capacity, i.e. the number of buckets; 
            max_bucket_count: returns the size of the maximum capacity of the bucket (return __stl_prime_list [( int ) __stl_num_primes- . 1 ]); 
            elems_in_bucket: returns the number of elements in a given bucket, bucket parameters noted Not exceed bucket_count, or it may throw an exception; 
            a resize: hashed containers readjust the tub and the tub layout of nodes; reset current practice is that if the element size greater than the current number of barrels __num_elements_hint container, reassigning apply a bucket container, the container and the original tub each node recalculates the tub placed 
            under each new tub (or the use of the first interpolation method) until completion, after which the cross call swap Tub container can affect the final bucket is generated and change the capacity of the container, the order of elements in each node is changed tub, Ruoruo __num_elements_hint reset element size smaller than the current container 
            barrels is no treatment;
            insert_unique_noresize: insert a unique value without changing the operation of the bucket container size; inner tub acquired first call _M_bkt_num insertion position of the current value can be set, after traversing all nodes in the current bucket is equal to compare function object by calling _M_get_key _M_equals and 
            extracted key to key comparison, if equal, means that the presence of the corresponding key, the insertion fails; if equal elements key are found, the call _M_new_node create the insert node and can be placed into the calculated position of the barrel by the first interpolation under; 
            _M_bkt_num: Get the current value of the element where the tub; internal key extraction function object _M_get_key acquired key and returns the call to the tub _M_bkt_num_key currently located; 
            _M_bkt_num_key: internal key as arguments to call the object hash function calculated _M_hash a hash value, this hash value to the number of containers required current bucket is the bucket position I is located, so the design object hash function affects the tub, the layout of data elements; 
            insert_unique: insert a unique value, achieved simply overload ; 
                insert the value specified for the internal version first call resize (_M_num_elem Ents + . 1  ) to adjust the layout of the tub, after calling insert_unique_noresize insert unique values without changing the size of the container bucket operation;
                before the input iterator parameter range version is based on the data type of extraction iterator type, call up the input iterator or implemented in different versions iterator input iterator version is for the value traversing call insert_unique insert iterator range, forward first by internal iterator version 
                acquired distance to the input iterator length range, and calls the resize adjustment barrel container, after insertion loop through call insert_unique_noresize iterator range of input values; this is for efficiency two versions; 
            insert_equal: insert element value equal to provide a number of heavy-duty version implements; insert_unique practices similar, the only difference is the internal insert_unique call insert_unique_noresize inserts a unique value, and insert_equal call insert_equal_noresize 
            insert a value equal elements to support multi-element holds the insert; 
            insert_equal_noresize: insert elements equal value does not change created and placed node is inserted into the corresponding bucket (first interpolation) operation bucket size of the container, with insert_unique_noresize similar, except when found equal elements internal key when inserted failure instead of returning Operation, 
            equal_range: Returns the specified key is equal to the container element iterator range, internal _M_bkt_num_key acquired key corresponding to the specified position by calling the tub, the tub traversing position and the position after _M_equals by determining whether equal time key until no equal iterator range;     
            ERASE: Removes the specified location iterator element or a key, several elements of a heavy-duty version iterator range;
                Removes the specified key element operable to remove all of the key element is equal to that acquired as internal operations call _M_bkt_num_key current key position where the barrel, the barrel traverse all the  
            node keys by comparing key equality _M_equals If the call is equal _M_delete_node remove the pointer to the node and to adjust the relationship between other nodes (removal of internal process operations of: sequentially comparing remove it from the second node at the start of the tank and adjust the node point, thereafter reprocessing
            first node); 
                Removes the specified version iterator position is to get to a position where the barrel through _M_bkt_num, removing nodes under the specified position and adjusts the node pointed to the relationship; 
                removing the iterator range version, get input iterator start and end position where the barrel, and call _ M_erase_bucket node is removed between the tub; 
            _M_erase_bucket: removing the specified node under the bucket position n, a plurality of heavy-duty version implements one element specified range iterator removal, in which all the elements of the tub where the iterator removed internal call _M_delete_node remove the corresponding node; 
            the find: find a container element specifies the key internal call _M_bkt_num_key get key position where the barrel, and in turn traversed node under the barrel, call _M_equals compare key, if found that the structure is returned iterator object, or an iterator object returns a failure; 
            find_or_insert: to find the specified value obj, Jordan Before the container is present, the corresponding value is returned, otherwise, the current value is inserted into a container; 
            moreover overloaded operator == operator, which when the two containers same bucket hash table size of the container, the value of each node at each barrel equal and corresponding to the number of nodes in each bucket was also equal returns true, otherwise both return to false; 
    
stl_hash_set.h:
    hash_set: hash_set container template, template parameters _Value, _HashFcn, _EqualKey, _Alloc corresponding value type, a hash function object type, the object type is equal to compare function key, and the memory allocation function; 
    default hash function to hash <_Value>, equal key comparison function equal_to < _Value> (internal overload operator () direct comparison value), the dispenser used as a default macro __STL_DEFAULT_ALLOCATOR dispenser; can be set by adjusting the macro, and therefore may be used allocator <T> or alloc (malloc_alloc (i.e. __malloc_alloc_template < 0 > ) 
    or __default_alloc_template <__ NODE_ALLOCATOR_THREADS, 0 > ) as the default allocator; 
    internal re-statement of various commonly used data types, iterators, pointers, and other types of reference; 
    data member: 
        _M_ht: hash table object as hash_set the underlying implementation, then the hash table _Key and template parameters are _Val _Value, the key parameter is extracted _Identity <_Value> (internal overload operator () directly as a return parameter value extracted key); 
    member functions : 
        constructors: providing more constructor implemented, including the number of initialization tub, hash function, key Equal to the comparison function, memory, a dispenser, wherein a number of an initialization 100 of the tub (in fact the bottom of the interior 193)
        Interface or similar interface corresponding to the name of other external interface is substantially a direct call of the hash table object _M_ht; 
     
    hash_multiset: with hash_set, but you can save the same key elements ; most fundamental difference is that the insert operation, hash_set internal call is insert_unique, and hash_multiset is insert_eq ual;
    
    addition for hash_set, hash_multiset insert iterator insert_iterator achieved (implemented primarily overloaded operator = operator (internal call the container insert achieve insertion operation)), can be easily implemented to support certain arithmetic operations; 

stl_hash_map.h: 
    hash_map: template hash_map container template parameters _Key, _Tp, _HashFcn, _EqualKey, _Alloc corresponding key type, the data type value, hash function object type, the object type is equal to compare function key, and the memory allocation function; 
    default hash function to the hash <_key>, equal key comparison function equal_to <_Key> (internal overload operator () direct comparison value) dispenser used as a default macro __STL_DEFAULT_ALLOCATOR dispenser; can be set by adjusting the macro, and therefore may be used allocator <T> or alloc (malloc_alloc (i.e. __malloc_alloc_template < 0 > ) 
    or __default_alloc_template <__ NODE_ALLOCATOR_THREADS, 0 > ) as the default memory the dispenser; 
    internal re-statement of various common data class , Iterators, pointers, and other types of reference; 
    data members: 
        _M_ht: hash table object, which is implemented as hash_map bottom, in which case Greek table template parameter is _Val pair < const_Key, _Tp>, the key parameter is extracted _Select1st <pair < const _key, _TP>> (internal Overload operator () Returns the pair of first parameter as extracted key); 
    member function: 
        Constructors: also offers a variety of constructor implemented, including the number of initialization tub, a hash function is equal to the comparison function keys, and other memory allocator, which provides a number of barrels is initialized 100 (in fact the bottom of the interior 193) 
        of other external interface is substantially an interface similar to the corresponding name or directly call the hashtable object _M_ht interface implementation; 
        
    hash_multimap: hash_map the same, but you can save the same key elements; the most fundamental difference is that the insert operation, internal hash_map call is insert_unique, and then hash_multimap is insert_equal, some other difference is the template template parameter types and parameters underlying hashtable object; 
    moreover, like hash_set, provides for hash_map, hash_multimap insert iterator insert_iterator, can facilitate the realization of certain algorithms support operations, in addition to providing the operator [] operator, which is the underlying implementation find_or_insert;
 
    associated container set, map, multimap, multiset for the core to achieve red-black tree _Rb_tree underlying core was achieved underlying hash associated container Ha table Xi hashtable, hashtable with respect to the red-black tree, is relatively simple to achieve, insert, remove, find other operations more efficient,
However, this depends on the capacity of the hash function and data elements, a red-black tree time complexity is a fixed time log (n).

 

Guess you like

Origin www.cnblogs.com/haomiao/p/11647257.html