avmplus::WeakKeyHashtable Class Reference

#include <avmplusHashtable.h>

Inheritance diagram for avmplus::WeakKeyHashtable:

avmplus::Hashtable MMgc::GCFinalizedObject MMgc::GCFinalizable List of all members.

Public Member Functions

 WeakKeyHashtable (MMgc::GC *gc)
void add (Atom key, Atom value)
Atom get (Atom key)
void remove (Atom key)
bool contains (Atom key)

Private Member Functions

Atom getKey (Atom key)
void prune ()

Detailed Description

If key is an object weak ref's are used

Definition at line 277 of file avmplusHashtable.h.


Constructor & Destructor Documentation

avmplus::WeakKeyHashtable::WeakKeyHashtable MMgc::GC gc  )  [inline]
 

Definition at line 280 of file avmplusHashtable.h.

00280 : Hashtable(gc) { };


Member Function Documentation

void avmplus::WeakKeyHashtable::add Atom  key,
Atom  value
 

Adds a name/value pair to a hash table. Automatically grows the hash table if it is full.

Reimplemented from avmplus::Hashtable.

Definition at line 335 of file avmplusHashtable.cpp.

References getKey(), avmplus::Hashtable::grow(), avmplus::Hashtable::isFull(), prune(), and avmplus::Hashtable::put().

Referenced by avmplus::MethodClosureClass::create(), and avmplus::DictionaryObject::setAtomProperty().

00336     {
00337         if(isFull()) {
00338             prune();
00339             grow();
00340         }
00341         put(getKey(key), value);
00342     }

bool avmplus::WeakKeyHashtable::contains Atom  key  )  [inline]
 

Definition at line 284 of file avmplusHashtable.h.

References avmplus::Hashtable::contains(), and getKey().

Referenced by avmplus::DictionaryObject::hasAtomProperty().

00284 { return Hashtable::contains(getKey(key)); }

Atom avmplus::WeakKeyHashtable::get Atom  key  )  [inline]
 

Definition at line 282 of file avmplusHashtable.h.

References avmplus::Hashtable::get(), and getKey().

Referenced by avmplus::MethodClosureClass::create(), and avmplus::DictionaryObject::getAtomProperty().

00282 { return Hashtable::get(getKey(key)); }

Atom avmplus::WeakKeyHashtable::getKey Atom  key  )  [private]
 

Definition at line 325 of file avmplusHashtable.cpp.

References avmplus::AvmCore::gcObjectToAtom(), MMgc::GCFinalizedObject::GetWeakRef(), and avmplus::AvmCore::isPointer().

Referenced by add(), contains(), get(), and remove().

00326     {
00327         // this gets a weak ref number, ie double keys, okay I guess
00328         if(AvmCore::isPointer(key)) {
00329             GCWeakRef *weakRef = ((GCObject*)(key&~7))->GetWeakRef();
00330             key = AvmCore::gcObjectToAtom(weakRef);
00331         }
00332         return key;
00333     }

void avmplus::WeakKeyHashtable::prune  )  [private]
 

Definition at line 344 of file avmplusHashtable.cpp.

References avmplus::Hashtable::atoms, avmplus::Hashtable::DELETED, avmplus::Hashtable::getNumAtoms(), util::threadpool::i, avmplus::AvmCore::isGCObject(), NULL, and avmplus::Hashtable::setHasDeletedItems().

Referenced by add().

00345     {
00346         for(int i=0, n=getNumAtoms(); i<n; i+=2) {
00347             if(AvmCore::isGCObject(atoms[i])) {
00348                 GCWeakRef *ref = (GCWeakRef*)(atoms[i]&~7);
00349                 if(ref && ref->get() == NULL) {
00350                     // inlined delete
00351                     atoms[i] = DELETED;
00352                     atoms[i+1] = DELETED;
00353                     setHasDeletedItems(true);
00354                 }
00355             }
00356         }
00357     }

void avmplus::WeakKeyHashtable::remove Atom  key  )  [inline]
 

Reimplemented from avmplus::Hashtable.

Definition at line 283 of file avmplusHashtable.h.

References getKey(), and avmplus::Hashtable::remove().

Referenced by avmplus::DictionaryObject::deleteAtomProperty().

00283 { Hashtable::remove(getKey(key)); }


The documentation for this class was generated from the following files:
Generated on Sun Oct 12 18:51:06 2008 for Tamarin by  doxygen 1.4.6