Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Static Private Attributes | Friends
basic_environment_rep Class Reference

#include <basic_environment.hpp>

Inheritance diagram for basic_environment_rep:
Inheritance graph
[legend]
Collaboration diagram for basic_environment_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 basic_environment_rep (int n2)
 ~basic_environment_rep ()
void raw_insert (int key, const tree &val)
void raw_write (int key, const tree &val)
treeraw_read (int key)
void raw_remove (int key)
void multiple_insert (hash_node *b, int k)
void multiple_write (hash_node *b, int k)
void multiple_remove (hash_node *b, int k)
void resize (int new_n)
bool contains (int key)
tree read (int key)
void write (int key, const tree &val)
void remove (int key)
void print (const string &prefix)
bool contains (const string &key)
tree read (const string &key)
void write (const string &key, const tree &val)
void remove (const string &key)

Public Attributes

int size
int n
hash_nodea
int free
int ref_count

Static Private Attributes

static tree uninit

Friends

class environment

Detailed Description

Definition at line 41 of file basic_environment.hpp.


Constructor & Destructor Documentation

Definition at line 50 of file basic_environment.hpp.

                                       :
    size (0), n (n2), a (tm_new_array<hash_node> (n)), free (0) {
      for (int i=0; i<n; i++) a[i].next= i+1; }

Definition at line 53 of file basic_environment.hpp.

Here is the call graph for this function:


Member Function Documentation

bool environment_rep::contains ( const string key) [inline, inherited]

Definition at line 59 of file environment.hpp.

                                           {
    return contains ((int) make_tree_label (key)); }

Here is the call graph for this function:

bool basic_environment_rep::contains ( int  key) [inline, virtual]

Implements environment_rep.

Definition at line 65 of file basic_environment.hpp.

                                 {
    return raw_read (key) != 0; }

Here is the call graph for this function:

Definition at line 89 of file basic_environment.cpp.

                                                           {
  for (int h=0; h<k; h++) {
    int i= b[h].start;
    while (i >= 0) {
      raw_insert (b[i].key, b[i].val);
      i= b[i].next;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 111 of file basic_environment.cpp.

                                                           {
  for (int h=0; h<k; h++) {
    int i= b[h].start;
    while (i >= 0) {
      raw_remove (b[i].key);
      i= b[i].next;
    }
  }
}

Here is the call graph for this function:

Definition at line 100 of file basic_environment.cpp.

                                                          {
  for (int h=0; h<k; h++) {
    int i= b[h].start;
    while (i >= 0) {
      raw_write (b[i].key, b[i].val);
      i= b[i].next;
    }
  }
}

Here is the call graph for this function:

void basic_environment_rep::print ( const string prefix) [virtual]

Implements environment_rep.

Definition at line 141 of file basic_environment.cpp.

                                                  {
  cout << prefix << "Basic environment" << LF;
  for (int h=0; h<n; h++) {
    int i= a[h].start;
    while (i >= 0) {
      cout << prefix << "| " << a[i].key
          << ": " << as_string ((tree_label) a[i].key)
          << " -> " << a[i].val << LF;
      i= a[i].next;
    }
  }
}

Here is the call graph for this function:

void basic_environment_rep::raw_insert ( int  key,
const tree val 
)

Definition at line 22 of file basic_environment.cpp.

                                                           {
  //cout << "Raw insert " << key << ", " << val << "\n";
  int h= key & (n-1), f= free;
  free      = a[f].next;
  a[f].key  = key;
  a[f].val  = val;
  a[f].next = a[h].start;
  a[h].start= f;
  size++;
}

Here is the caller graph for this function:

Definition at line 54 of file basic_environment.cpp.

                                        {
  //cout << "Raw read " << key << "\n";
  int h= key & (n-1), i= a[h].start;
  while (i >= 0) {
    if (a[i].key == key)
      return & (a[i].val);
    i= a[i].next;
  }
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 66 of file basic_environment.cpp.

                                          {
  //cout << "Raw remove " << key << "\n";
  int h= key & (n-1), i= a[h].start, p= -1;
  while (i >= 0) {
    if (a[i].key == key) {
      a[i].val= uninit;
      if (p >= 0) a[p].next= a[i].next;
      else a[h].start= a[i].next;
      a[i].next= free;
      free= i;
      size--;
      return;
    }
    p= i;
    i= a[i].next;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void basic_environment_rep::raw_write ( int  key,
const tree val 
)

Definition at line 34 of file basic_environment.cpp.

                                                          {
  //cout << "Raw write " << key << ", " << val << "\n";
  int h= key & (n-1), i= a[h].start;
  while (i >= 0) {
    if (a[i].key == key) {
      a[i].val= val;
      return;
    }
    i= a[i].next;
  }
  int f= free;
  free      = a[f].next;
  a[f].key  = key;
  a[f].val  = val;
  a[f].next = a[h].start;
  a[h].start= f;
  size++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree environment_rep::read ( const string key) [inline, inherited]

Definition at line 61 of file environment.hpp.

                                       {
    return read ((int) make_tree_label (key)); }

Here is the call graph for this function:

tree basic_environment_rep::read ( int  key) [inline, virtual]

Implements environment_rep.

Definition at line 67 of file basic_environment.hpp.

                             {
    tree* ptr= raw_read (key);
    return ptr==NULL? uninit: *ptr; }

Here is the call graph for this function:

void environment_rep::remove ( const string key) [inline, inherited]

Definition at line 65 of file environment.hpp.

                                         {
    remove ((int) make_tree_label (key)); }

Here is the call graph for this function:

void basic_environment_rep::remove ( int  key) [inline, virtual]

Implements environment_rep.

Definition at line 73 of file basic_environment.hpp.

                               {
    raw_remove (key);
    if (size < (n>>2)) resize (n>>1); }

Here is the call graph for this function:

void basic_environment_rep::resize ( int  new_n)

Definition at line 122 of file basic_environment.cpp.

                                        {
  //cout << "Resize " << n << " -> " << new_n << " (" << size << ")\n";
  ASSERT (new_n >= size, "too small number of bags");
  int old_n= n;
  hash_node* old_a= a;
  n= new_n;
  a= tm_new_array<hash_node> (n);
  size= 0;
  free= 0;
  for (int i=0; i<n; i++)
    a[i].next= i+1;
  multiple_insert (old_a, old_n);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void environment_rep::write ( const string key,
const tree val 
) [inline, inherited]

Definition at line 63 of file environment.hpp.

                                                         {
    write ((int) make_tree_label (key), val); }

Here is the call graph for this function:

void basic_environment_rep::write ( int  key,
const tree val 
) [inline, virtual]

Implements environment_rep.

Definition at line 70 of file basic_environment.hpp.

                                               {
    if (size >= n) resize (n << 1);
    raw_write (key, val); }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class environment [friend, inherited]

Definition at line 68 of file environment.hpp.


Member Data Documentation

Definition at line 46 of file basic_environment.hpp.

Definition at line 47 of file basic_environment.hpp.

Definition at line 45 of file basic_environment.hpp.

int concrete_struct::ref_count [inherited]

Definition at line 135 of file basic.hpp.

Definition at line 44 of file basic_environment.hpp.

Definition at line 42 of file basic_environment.hpp.


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