Ignore:
Timestamp:
Sep 4, 2007, 10:01:03 PM (18 years ago)
Author:
mjs
Message:

Reviewed by Darin.


  • Added Vector::appendRange(), which appends to a vector based on a given start and end iterator
  • Added keys() and values() functions to HashMap iterators, which give keys-only and values-only iterators


Together, these allow easy copying of a set, or the keys or values of a map, into a Vector. Examples:


HashMap<int, int> map;
HashSet<int> set;
Vector<int> vec;
...
vec.appendRange(set.begin(), set.end());
vec.appendRange(map.begin().keys(), map.end().keys());
vec.appendRange(map.begin().values(), map.end().values());

This also allows for a slightly nicer syntax when iterating a map. Instead of saying
(*it)->first, you can say *it.values(). Similarly for keys. Example:


HashMap<int, int>::const_iterator end = map.end();
for (HashMap<int, int>::const_iterator it = map.begin(); it != end; ++it)
printf(" [%d => %d]", *it.keys(), *it.values());

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • wtf/HashIterators.h: Added. (WTF::): (WTF::HashTableConstKeysIterator::HashTableConstKeysIterator): (WTF::HashTableConstKeysIterator::get): (WTF::HashTableConstKeysIterator::operator*): (WTF::HashTableConstKeysIterator::operator->): (WTF::HashTableConstKeysIterator::operator++): (WTF::HashTableConstValuesIterator::HashTableConstValuesIterator): (WTF::HashTableConstValuesIterator::get): (WTF::HashTableConstValuesIterator::operator*): (WTF::HashTableConstValuesIterator::operator->): (WTF::HashTableConstValuesIterator::operator++): (WTF::HashTableKeysIterator::HashTableKeysIterator): (WTF::HashTableKeysIterator::get): (WTF::HashTableKeysIterator::operator*): (WTF::HashTableKeysIterator::operator->): (WTF::HashTableKeysIterator::operator++): (WTF::HashTableKeysIterator::operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>): (WTF::HashTableValuesIterator::HashTableValuesIterator): (WTF::HashTableValuesIterator::get): (WTF::HashTableValuesIterator::operator*): (WTF::HashTableValuesIterator::operator->): (WTF::HashTableValuesIterator::operator++): (WTF::HashTableValuesIterator::operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType>): (WTF::operator==): (WTF::operator!=):
  • wtf/HashTable.h:
  • wtf/Vector.h: (WTF::::appendRange):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r25349 r25365  
    8484                5DBD18AC0C54018700C15EAE /* CollectorHeapIntrospector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DBD18AA0C54018700C15EAE /* CollectorHeapIntrospector.h */; };
    8585                5DBD18B00C5401A700C15EAE /* MallocZoneSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */; };
     86                652246A50C8D7A0E007BDAF7 /* HashIterators.h in Headers */ = {isa = PBXBuildFile; fileRef = 652246A40C8D7A0E007BDAF7 /* HashIterators.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8687                65400C120A69BAF200509887 /* PropertyNameArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 65400C100A69BAF200509887 /* PropertyNameArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8788                6541BD7208E80A17002CBEE7 /* TCPageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6E08E80A17002CBEE7 /* TCPageMap.h */; };
     
    103104                65C7A1740A8EAACB00FA37EA /* JSWrapperObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
    104105                65D6D87F09B5A32E0002E4D7 /* Platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D6D87E09B5A32E0002E4D7 /* Platform.h */; settings = {ATTRIBUTES = (Private, ); }; };
    105                 65D7D19C08F10B5B0015ABD8 /* FastMallocInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */; };
    106106                65DFC93008EA173A00F7300B /* HashFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92A08EA173A00F7300B /* HashFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    107107                65DFC93108EA173A00F7300B /* HashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92B08EA173A00F7300B /* HashMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    488488                651F6412039D5B5F0078395C /* dtoa.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dtoa.cpp; sourceTree = "<group>"; tabWidth = 8; };
    489489                651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; tabWidth = 8; };
     490                652246A40C8D7A0E007BDAF7 /* HashIterators.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashIterators.h; sourceTree = "<group>"; };
    490491                65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyNameArray.cpp; sourceTree = "<group>"; };
    491492                65400C100A69BAF200509887 /* PropertyNameArray.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PropertyNameArray.h; sourceTree = "<group>"; };
     
    517518                65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSWrapperObject.h; sourceTree = "<group>"; };
    518519                65D6D87E09B5A32E0002E4D7 /* Platform.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; };
    519                 65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = FastMallocInternal.h; sourceTree = "<group>"; tabWidth = 8; };
    520520                65DFC92A08EA173A00F7300B /* HashFunctions.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HashFunctions.h; sourceTree = "<group>"; tabWidth = 8; };
    521521                65DFC92B08EA173A00F7300B /* HashMap.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HashMap.h; sourceTree = "<group>"; tabWidth = 8; };
     
    894894                        isa = PBXGroup;
    895895                        children = (
     896                                652246A40C8D7A0E007BDAF7 /* HashIterators.h */,
    896897                                E195678D09E7CF1200B89D13 /* unicode */,
    897898                                93AA4F770957251F0084B3A7 /* AlwaysInline.h */,
     
    900901                                65E217B908E7EECC0023E5F6 /* FastMalloc.cpp */,
    901902                                65E217BA08E7EECC0023E5F6 /* FastMalloc.h */,
    902                                 65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */,
    903903                                9302043A0B790750000C6115 /* FastMallocPCRE.cpp */,
    904904                                935AF46909E9D9DB00ACD1D8 /* Forward.h */,
     
    11941194                                65DFC93408EA173A00F7300B /* HashTable.h in Headers */,
    11951195                                65DFC93508EA173A00F7300B /* HashTraits.h in Headers */,
    1196                                 65D7D19C08F10B5B0015ABD8 /* FastMallocInternal.h in Headers */,
    11971196                                65EA4C9C092AF9E20093D800 /* JSLock.h in Headers */,
    11981197                                65C647B4093EF8D60022C380 /* RefPtr.h in Headers */,
     
    12501249                                5DBD18AC0C54018700C15EAE /* CollectorHeapIntrospector.h in Headers */,
    12511250                                5DBD18B00C5401A700C15EAE /* MallocZoneSupport.h in Headers */,
     1251                                652246A50C8D7A0E007BDAF7 /* HashIterators.h in Headers */,
    12521252                        );
    12531253                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.