Back to index

texmacs  1.0.7.15
Public Member Functions | Private Attributes | Friends
hashset_rep< T > Class Template Reference

#include <hashset.hpp>

Inheritance diagram for hashset_rep< T >:
Inheritance graph
[legend]
Collaboration diagram for hashset_rep< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 hashset_rep ()
 hashset_rep (int n2, int max2=1)
 ~hashset_rep ()
bool contains (T x)
void resize (int n)
void insert (T x)
void remove (T x)

Private Attributes

int size
int n
int max
list< T > * a
int ref_count

Friends

class hashset< T >
class hashset_iterator_rep< T >
int N LESSGTR (hashset< T > h)
tm_ostreamoperator<< LESSGTR (tm_ostream &out, hashset< T > h)
bool operator<=LESSGTR (hashset< T > h1, hashset< T > h2)

Detailed Description

template<class T>
class hashset_rep< T >

Definition at line 22 of file hashset.hpp.


Constructor & Destructor Documentation

template<class T >
hashset_rep< T >::hashset_rep ( ) [inline]

Definition at line 29 of file hashset.hpp.

                       :
    size(0), n(1), max(1), a (tm_new_array<list<T> > (1)) {}
template<class T >
hashset_rep< T >::hashset_rep ( int  n2,
int  max2 = 1 
) [inline]

Definition at line 31 of file hashset.hpp.

                                        :
    size(0), n(n2), max(max2), a (tm_new_array<list<T> > (n)) {}
template<class T >
hashset_rep< T >::~hashset_rep ( ) [inline]

Definition at line 33 of file hashset.hpp.

Here is the call graph for this function:


Member Function Documentation

template<class T >
bool hashset_rep< T >::contains ( T  x)

Definition at line 44 of file hashset.cpp.

                             {
  return (search (a[hash(x)&(n-1)], x)==NULL? false: true);
}

Here is the call graph for this function:

template<class T >
void hashset_rep< T >::insert ( T  x)

Definition at line 49 of file hashset.cpp.

                           {
  if (size==n*max) resize (n << 1);
  list<T>& l= a[hash(x)&(n-1)];
  if (search (l, x) != NULL) return;
  l= list<T> (x, l);
  size ++;
}

Here is the call graph for this function:

template<class T >
void hashset_rep< T >::remove ( T  x)

Definition at line 58 of file hashset.cpp.

                           {
  list<T>* lptr= &a[hash(x)&(n-1)];
  while (!is_nil (*lptr)) {
    if ((*lptr)->item==x) {
      *lptr=(*lptr)->next;
      size --;
      return;
    }
    lptr=&((*lptr)->next);
  }
}

Here is the call graph for this function:

template<class T >
void hashset_rep< T >::resize ( int  n)

Definition at line 17 of file hashset.cpp.

                              {
  int i;
  int oldn= n;
  list<T>* olda= a;
  n= n2;
  a= tm_new_array<list<T> > (n);
  for (i=0; i<oldn; i++) {
    list<T> l(olda[i]);
    while (!is_nil(l)) {
      list<T>& newl= a[hash(l->item)&(n-1)];
      newl= list<T> (l->item, newl);
      l=l->next;
    }
  }
  tm_delete_array (olda);
}

Here is the call graph for this function:


Friends And Related Function Documentation

template<class T >
friend class hashset< T > [friend]

Definition at line 40 of file hashset.hpp.

template<class T >
friend class hashset_iterator_rep< T > [friend]

Definition at line 44 of file hashset.hpp.

template<class T >
int N LESSGTR ( hashset< T h) [friend]
template<class T >
tm_ostream& operator<< LESSGTR ( tm_ostream out,
hashset< T h 
) [friend]
template<class T >
bool operator<=LESSGTR ( hashset< T h1,
hashset< T h2 
) [friend]

Member Data Documentation

template<class T >
list<T>* hashset_rep< T >::a [private]

Definition at line 26 of file hashset.hpp.

template<class T >
int hashset_rep< T >::max [private]

Definition at line 25 of file hashset.hpp.

template<class T >
int hashset_rep< T >::n [private]

Definition at line 24 of file hashset.hpp.

int concrete_struct::ref_count [inherited]

Definition at line 135 of file basic.hpp.

template<class T >
int hashset_rep< T >::size [private]

Definition at line 23 of file hashset.hpp.


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