зеркало из https://github.com/mozilla/pjs.git
Added the clone method. Approved by warren
This commit is contained in:
Родитель
43a19aa22a
Коммит
ca98fa5189
|
@ -137,6 +137,20 @@ void *nsHashtable::Remove(nsHashKey *aKey) {
|
|||
return res;
|
||||
}
|
||||
|
||||
static PR_CALLBACK PRIntn _hashEnumerateCopy(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
nsHashtable *newHashtable = (nsHashtable *)arg;
|
||||
newHashtable->Put((nsHashKey *) he->key, he->value);
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
nsHashtable * nsHashtable::Clone() {
|
||||
nsHashtable *newHashTable = new nsHashtable(hashtable->nentries);
|
||||
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerateCopy, newHashTable);
|
||||
return newHashTable;
|
||||
}
|
||||
|
||||
void nsHashtable::Enumerate(nsHashtableEnumFunc aEnumFunc) {
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, aEnumFunc);
|
||||
}
|
||||
|
|
|
@ -137,6 +137,20 @@ void *nsHashtable::Remove(nsHashKey *aKey) {
|
|||
return res;
|
||||
}
|
||||
|
||||
static PR_CALLBACK PRIntn _hashEnumerateCopy(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
nsHashtable *newHashtable = (nsHashtable *)arg;
|
||||
newHashtable->Put((nsHashKey *) he->key, he->value);
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
nsHashtable * nsHashtable::Clone() {
|
||||
nsHashtable *newHashTable = new nsHashtable(hashtable->nentries);
|
||||
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerateCopy, newHashTable);
|
||||
return newHashTable;
|
||||
}
|
||||
|
||||
void nsHashtable::Enumerate(nsHashtableEnumFunc aEnumFunc) {
|
||||
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, aEnumFunc);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
void *Put(nsHashKey *aKey, void *aData);
|
||||
void *Get(nsHashKey *aKey);
|
||||
void *Remove(nsHashKey *aKey);
|
||||
nsHashtable *Clone();
|
||||
void Enumerate(nsHashtableEnumFunc aEnumFunc);
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче