Back to index

plt-scheme  4.2.1
Public Member Functions | Private Attributes
wxNonlockingHashTable Class Reference

#include <wx_hash.h>

Collaboration diagram for wxNonlockingHashTable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 wxNonlockingHashTable (void)
 ~wxNonlockingHashTable ()
void Put (long widget, wxObject *object)
wxObjectGet (long widget)
void Delete (long widget)
void DeleteObject (wxObject *object)
void Append (long w, wxObject *o)
wxObjectFind (long w)

Private Attributes

struct Bucketbuckets
long numbuckets
long numwidgets
long numused

Detailed Description

Definition at line 81 of file wx_hash.h.


Constructor & Destructor Documentation

Definition at line 275 of file wb_hash.cxx.

{
  long i;
  Bucket *bs;

  numbuckets = 1001;
  bs = (Bucket *)nl_malloc_bucket_array(sizeof(Bucket) * numbuckets);
  buckets = bs;
  for (i = 0; i < numbuckets; i++) {
    buckets[i].widget = 0;
  }
  numwidgets = numused = 0;
}

Definition at line 289 of file wb_hash.cxx.

{
}

Member Function Documentation

void wxNonlockingHashTable::Append ( long  w,
wxObject o 
) [inline]

Definition at line 92 of file wx_hash.h.

{ Put(w, o); }

Here is the call graph for this function:

Definition at line 353 of file wb_hash.cxx.

{
  long i;

  i = HASH(widget);
  while (buckets[i].widget && (nlGET_WIDGET(buckets[i].widget) != widget)) {
    i = (i + 1) % numbuckets;
  }

  if (buckets[i].widget && (nlGET_WIDGET(buckets[i].widget) == widget)) {
    buckets[i].object = NULL;
    --numwidgets;
    /* Don't decrement numused, since the widget half is still set;
       we should re-hash after enough deletions */
  }
}

Here is the caller graph for this function:

Definition at line 371 of file wb_hash.cxx.

{
  long i;
  
  for (i = 0; i < numbuckets; i++) {
    if (buckets[i].widget && buckets[i].object && nlGET_OBJECT(buckets[i].object) == o)
      Delete(nlGET_WIDGET(buckets[i].widget));
  }
}

Here is the call graph for this function:

wxObject* wxNonlockingHashTable::Find ( long  w) [inline]

Definition at line 93 of file wx_hash.h.

{ return Get(w); }

Here is the call graph for this function:

Definition at line 333 of file wb_hash.cxx.

{
  long i;

  i = HASH(widget);
  while (buckets[i].widget && (nlGET_WIDGET(buckets[i].widget) != widget)) {
    i = (i + 1) % numbuckets;
  }

  if (buckets[i].widget 
      && (nlGET_WIDGET(buckets[i].widget) == widget)
      && buckets[i].object) {
    wxObject *r;
    r = nlGET_OBJECT(buckets[i].object);
    return r;
  }

  return NULL;
}

Here is the caller graph for this function:

void wxNonlockingHashTable::Put ( long  widget,
wxObject object 
)

Definition at line 293 of file wb_hash.cxx.

{
  long i;

  if (FILL_FACTOR * numused >= numbuckets) {
    /* Rehash */
    Bucket *oldbuckets = buckets, *bs;
    long oldnumbuckets = numbuckets;

    if (FILL_FACTOR * numwidgets >= numbuckets)
      numbuckets = (numbuckets * FILL_FACTOR) + 1;
    /* else, just need to rehash after many deletions */

    bs = (Bucket *)nl_malloc_bucket_array(sizeof(Bucket) * numbuckets);
    buckets = bs;
    for (i = 0; i < numbuckets; i++) {
      buckets[i].widget = 0;
    }

    numwidgets = numused = 0;
    for (i = 0; i < oldnumbuckets; i++) {
      if (oldbuckets[i].widget && oldbuckets[i].object)
       Put(nlGET_WIDGET(oldbuckets[i].widget), nlGET_OBJECT(oldbuckets[i].object));
    }
  }

  i = HASH(widget);
  while (buckets[i].widget && buckets[i].object
        && (nlGET_WIDGET(buckets[i].widget) != widget)) {
    i = (i + 1) % numbuckets;
  }
  if (!buckets[i].widget)
    numused++;
  nlALLOC_WIDGET(buckets[i].widget);
  nlGET_WIDGET(buckets[i].widget) = widget;
  nlALLOC_OBJECT(buckets[i].object);
  nlGET_OBJECT(buckets[i].object) = object;
  numwidgets++;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 83 of file wx_hash.h.

Definition at line 84 of file wx_hash.h.

Definition at line 84 of file wx_hash.h.

Definition at line 84 of file wx_hash.h.


The documentation for this class was generated from the following files: