Back to index

texmacs  1.0.7.15
Classes | Defines | Functions
hashmap.hpp File Reference
#include "list.hpp"
#include "hashmap.cpp"
#include "hashmap_extra.cpp"

Go to the source code of this file.

Classes

struct  hashentry< T, U >
class  hashmap_rep< T, U >
class  hashmap< T, U >

Defines

#define TMPL   template<class T, class U>

Functions

template<class T , class U >
int N (hashmap< T, U > a)
template<class T , class U >
tm_ostreamoperator<< (tm_ostream &out, hashmap< T, U > h)
template<class T , class U >
hashmap< T, U > copy (hashmap< T, U > h)
template<class T , class U >
hashmap< T, U > changes (hashmap< T, U > p, hashmap< T, U > b)
template<class T , class U >
hashmap< T, U > invert (hashmap< T, U > p, hashmap< T, U > b)
template<class T , class U >
bool operator== (hashmap< T, U > h1, hashmap< T, U > h2)
template<class T , class U >
bool operator!= (hashmap< T, U > h1, hashmap< T, U > h2)
 CONCRETE_TEMPLATE_2_CODE (hashmap, class, T, class, U)

Define Documentation

#define TMPL   template<class T, class U>

Definition at line 98 of file hashmap.hpp.


Function Documentation

template<class T , class U >
TMPL hashmap< T, U > changes ( hashmap< T, U >  p,
hashmap< T, U >  b 
)

Definition at line 90 of file hashmap_extra.cpp.

                                                {
  int i;
  hashmap<T,U> h (base->init);
  for (i=0; i<patch->n; i++) {
    list<hashentry<T,U> > l (patch->a[i]);
    while (!is_nil (l)) {
      if (l->item.im != base [l->item.key])
       h (l->item.key)= l->item.im;
      l=l->next;
    }
  }
  return h;
}

Here is the call graph for this function:

CONCRETE_TEMPLATE_2_CODE ( hashmap  ,
class  ,
T  ,
class  ,
 
)
template<class T , class U >
hashmap<T,U> copy ( hashmap< T, U >  h)

Definition at line 80 of file hashmap_extra.cpp.

                      {
  int i, n= h->n;
  hashmap<T,U> h2 (h->init, n, h->max);
  h2->size= h->size;
  for (i=0; i<n; i++)
    h2->a[i]= copy_list (h->a[i]);
  return h2;
}

Here is the call graph for this function:

template<class T , class U >
TMPL hashmap< T, U > invert ( hashmap< T, U >  p,
hashmap< T, U >  b 
)

Definition at line 105 of file hashmap_extra.cpp.

                                               {
  int i;
  hashmap<T,U> h (base->init);
  for (i=0; i<patch->n; i++) {
    list<hashentry<T,U> > l (patch->a[i]);
    while (!is_nil (l)) {
      if (l->item.im != base [l->item.key])
       h (l->item.key)= base [l->item.key];
      l=l->next;
    }
  }
  return h;
}

Here is the call graph for this function:

template<class T , class U >
TMPL int N ( hashmap< T, U >  a) [inline]

Definition at line 99 of file hashmap.hpp.

{ return h->size; }
template<class T , class U >
bool operator!= ( hashmap< T, U >  h1,
hashmap< T, U >  h2 
)

Definition at line 187 of file hashmap.cpp.

                                               {
  return !(h1 == h2);
}
template<class T , class U >
tm_ostream& operator<< ( tm_ostream out,
hashmap< T, U >  h 
)

Definition at line 139 of file hashmap.cpp.

                                              {
  int i= 0, j= 0, n= h->n, size= h->size;
  out << "{ ";
  for (; i<n; i++) {
    list<hashentry<T,U> > l= h->a[i];
    for (; !is_nil (l); l= l->next, j++) {
      out << l->item;
      if (j != size-1) out << ", ";
    }
  }
  out << " }";
  return out;
}

Here is the call graph for this function:

template<class T , class U >
bool operator== ( hashmap< T, U >  h1,
hashmap< T, U >  h2 
)

Definition at line 175 of file hashmap.cpp.

                                               {
  if (h1->size != h2->size) return false;
  int i= 0, n= h1->n;
  for (; i<n; i++) {
    list<hashentry<T,U> > l= h1->a[i];
    for (; !is_nil(l); l=l->next)
      if (h2[l->item.key] != l->item.im) return false;
  }
  return true;
}

Here is the call graph for this function: