Changeset 28132 in webkit for trunk/JavaScriptCore/wtf/HashMap.h


Ignore:
Timestamp:
Nov 28, 2007, 10:04:21 PM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoff

Add copyKeysToVector utility, mirroring copyValuesToVector
Also change the copyValuesToVector implementation to be a little more attractive

  • wtf/HashMap.h: (WTF::copyKeysToVector): (WTF::copyValuesToVector):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/HashMap.h

    r27710 r28132  
    395395   
    396396    template<typename T, typename U, typename V, typename W, typename X>
    397     inline void copyValuesToVector(const HashMap<T, U, V, W, X>& collection, Vector<U>& vector)
    398     {
    399         typedef typename HashMap<T, U, V, W, X>::const_iterator iterator;
     397    inline void copyKeysToVector(const HashMap<T, U, V, W, X>& collection, Vector<T>& vector)
     398    {
     399        typedef typename HashMap<T, U, V, W, X>::const_iterator::Keys iterator;
    400400       
    401401        vector.resize(collection.size());
    402402       
    403         iterator it = collection.begin();
    404         iterator end = collection.end();
     403        iterator it = collection.begin().keys();
     404        iterator end = collection.end().keys();
    405405        for (unsigned i = 0; it != end; ++it, ++i)
    406             vector[i] = (*it).second;
     406            vector[i] = *it;
     407    } 
     408
     409    template<typename T, typename U, typename V, typename W, typename X>
     410    inline void copyValuesToVector(const HashMap<T, U, V, W, X>& collection, Vector<U>& vector)
     411    {
     412        typedef typename HashMap<T, U, V, W, X>::const_iterator::Values iterator;
     413       
     414        vector.resize(collection.size());
     415       
     416        iterator it = collection.begin().values();
     417        iterator end = collection.end().values();
     418        for (unsigned i = 0; it != end; ++it, ++i)
     419            vector[i] = *it;
    407420    }   
    408421
Note: See TracChangeset for help on using the changeset viewer.