new_table_rep< C, T, V > Class Template Reference

#include <new_table.hpp>

Inheritance diagram for new_table_rep< C, T, V >:
rep_struct encapsulate1< format< C > > encapsulate2< format< T > > format< C > format< T > empty_format empty_format

List of all members.

Public Types

Public Member Functions

Public Attributes

Friends


Detailed Description

template<typename C, typename T, typename V = exact_eq_table>
class mmx::new_table_rep< C, T, V >

Definition at line 81 of file new_table.hpp.


Member Typedef Documentation

typedef empty_format FT [inherited]

Definition at line 196 of file type_props.hpp.

typedef empty_format FT [inherited]

Definition at line 196 of file type_props.hpp.


Constructor & Destructor Documentation

new_table_rep ( nat  n2,
const format< C > &  fm1,
const format< T > &  fm2 
) [inline]
new_table_rep ( const C init2,
nat  n2,
const format< T > &  fm2 
) [inline]
~new_table_rep (  )  [inline]

Member Function Documentation

double complexity (  )  const [inline]

Definition at line 409 of file new_table.hpp.

00409                              {
00410   double sum= 0.0;
00411   //mmout << "{";
00412   for (nat i=0; i<n; i++) {
00413     for (nat j=0; j<n; j++)
00414       if ((a + ((i+j) & mask))->x1 == 0) {
00415         sum += ((double) j) * ((double) j);
00416         break;
00417       }
00418     //mmout << " " << l;
00419   }
00420   //mmout << " }";
00421   return sum / n;
00422 }

bool contains ( const T x  )  const [inline]

Definition at line 303 of file new_table.hpp.

References new_table_rep< C, T, V >::find().

00303                                      {
00304   return find (x) < n;
00305   /*
00306   nat code= V::key_op::hash_op (x) | hibit_mask;
00307   nat addr= code & mask;
00308   while (true) {
00309     Triple* cur= a + addr;
00310     nat stamp= cur->x1;
00311     if (stamp == 0) return false;
00312     if (stamp == code && cur->x2 == x) return true;
00313     addr= (addr + 1) & mask;
00314   }
00315   */
00316 }

nat find ( const T x  )  const [inline]

Definition at line 269 of file new_table.hpp.

References mmx::hibit_mask, and Triple.

Referenced by new_table_rep< C, T, V >::contains(), new_table_rep< C, T, V >::get(), and new_table_rep< C, T, V >::reset().

00269                                  {
00270   nat code= V::key_op::hash_op (x) | hibit_mask;
00271   nat addr= code & mask;
00272   while (true) {
00273     Triple* cur= a + addr;
00274     nat stamp= cur->x1;
00275     if (stamp == 0) return n;
00276     if (stamp == code && cur->x2 == x) return addr;
00277     addr= (addr + 1) & mask;
00278   }
00279 }

empty_format format1 (  )  const [inline, inherited]

Definition at line 189 of file type_props.hpp.

Referenced by mmx::get_format1().

00189 { return empty_format (); }

empty_format format1 (  )  const [inline, inherited]

Definition at line 189 of file type_props.hpp.

Referenced by mmx::get_format1().

00189 { return empty_format (); }

empty_format format2 (  )  const [inline, inherited]

Definition at line 190 of file type_props.hpp.

Referenced by mmx::get_format2().

00190 { return empty_format (); }

empty_format format2 (  )  const [inline, inherited]

Definition at line 190 of file type_props.hpp.

Referenced by mmx::get_format2().

00190 { return empty_format (); }

empty_format format3 (  )  const [inline, inherited]

Definition at line 191 of file type_props.hpp.

00191 { return empty_format (); }

empty_format format3 (  )  const [inline, inherited]

Definition at line 191 of file type_props.hpp.

00191 { return empty_format (); }

const C & get ( const T x  )  const [inline]

Definition at line 341 of file new_table.hpp.

References new_table_rep< C, T, V >::find(), and new_table_rep< C, T, V >::lazy_initialize().

00341                                 {
00342   nat addr= find (x);
00343   if (addr < n) return (a + addr)->x3;
00344   lazy_initialize ();
00345   return *init;
00346   /*
00347   nat code= V::key_op::hash_op (x) | hibit_mask;
00348   nat addr= code & mask;
00349   while (true) {
00350     Triple* cur= a + addr;
00351     nat stamp= cur->x1;
00352     if (stamp == 0) {
00353       lazy_initialize ();
00354       return *init;
00355     }
00356     if (stamp == code && cur->x2 == x) return cur->x3;
00357     addr= (addr + 1) & mask;
00358   }
00359   */
00360 }

bool get ( const T x,
C y 
) const [inline]

Definition at line 319 of file new_table.hpp.

References new_table_rep< C, T, V >::find().

00319                                       {
00320   nat addr= find (x);
00321   if (addr >= n) return false;
00322   y= (a + addr)->x3;
00323   return true;
00324   /*
00325   nat code= V::key_op::hash_op (x) | hibit_mask;
00326   nat addr= code & mask;
00327   while (true) {
00328     Triple* cur= a + addr;
00329     nat stamp= cur->x1;
00330     if (stamp == 0) return false;
00331     if (stamp == code && cur->x2 == x) {
00332       y= cur->x3;
00333       return true;
00334     }
00335     addr= (addr + 1) & mask;
00336   }
00337   */
00338 }

void lazy_initialize (  )  const [inline]

Definition at line 123 of file new_table.hpp.

References mmx::C.

Referenced by new_table_rep< C, T, V >::get(), new_table_rep< C, T, V >::set(), and new_table_rep< C, T, V >::simplify().

00123                                        {
00124     if (init == NULL) {
00125       *((C**) ((void*) &init))= mmx_new_one<C> ();
00126       //mmout << "[:init=" << init << "," << this
00127       //<< ";" << ((int*) ((void*) init))[-1]
00128       //<< "]" << flush_now;
00129     }
00130   }

void remove ( nat  addr  )  const [inline]

Definition at line 282 of file new_table.hpp.

References mmx::mmx_delete_at(), and Triple.

00282                                  {
00283   Triple* cur= a + addr;
00284   nat old_addr= addr;
00285   Triple* old_cur= cur;
00286   while (true) {
00287     addr= (addr + 1) & mask;
00288     cur= a + addr;
00289     nat stamp= cur->x1;
00290     if (stamp == 0) break;
00291     nat item_addr= stamp & mask;
00292     if (((item_addr - old_addr - 1) % mask) > ((addr - old_addr) % mask)) {
00293       *old_cur= *cur;
00294       old_cur = cur;
00295       old_addr= addr;
00296     }
00297   }
00298   mmx_delete_at (old_cur);
00299   old_cur->x1= 0;
00300 }

void reset ( const T x  )  [inline]

Definition at line 392 of file new_table.hpp.

References new_table_rep< C, T, V >::find(), and new_table_rep< C, T, V >::resize().

00392                             {
00393   nat addr= find (x);
00394   if (addr >= n) return;
00395   remove (addr);
00396   if ((size << 3) < n) resize (n>>1);
00397 }

void resize ( nat  n  )  [inline]

Definition at line 249 of file new_table.hpp.

References mmx::mmx_delete_at(), and Triple.

Referenced by new_table_rep< C, T, V >::reset(), new_table_rep< C, T, V >::set(), and new_table_rep< C, T, V >::simplify().

00249                          {
00250   nat     old_n= n;
00251   Triple* old_a= a;
00252 
00253   n   = n2;
00254   mask= n-1;
00255   a   = mmx_new_uninitialized<Triple > (n);
00256 
00257   for (nat i=0; i<old_n; i++) {
00258     Triple* cur= old_a + i;
00259     if (cur->x1 != 0) {
00260       set (cur->x2)= cur->x3;
00261       mmx_delete_at (cur);
00262     }
00263   }
00264 
00265   mmx_delete_uninitialized<Triple > (old_a, old_n);
00266 }

empty_format rfm (  )  const [inline, inherited]

Definition at line 188 of file type_props.hpp.

00188 { return *this; }

empty_format rfm (  )  const [inline, inherited]

Definition at line 188 of file type_props.hpp.

00188 { return *this; }

T sample (  )  const [inline, inherited]

Definition at line 202 of file type_props.hpp.

00202 { return C(); }

C sample (  )  const [inline, inherited]

Definition at line 202 of file type_props.hpp.

Referenced by mmx::get_sample().

00202 { return C(); }

C & set ( const T x  )  [inline]

Definition at line 363 of file new_table.hpp.

References mmx::hibit_mask, new_table_rep< C, T, V >::lazy_initialize(), mmx::mmx_new_at(), new_table_rep< C, T, V >::resize(), Triple, and triple< C1, C2, C3 >::x1.

00363                           {
00364   if ((size<<1) >= n) {
00365     //mmout << "size= " << size << ", n= " << n << "\n";
00366     resize (n<<1);
00367     //mmout << "Resized\n";
00368   }
00369 
00370   nat code= V::key_op::hash_op (x) | hibit_mask;
00371   nat addr= code & mask;
00372   Triple* cur;
00373   nat stamp;
00374   while (true) {
00375     cur= a + addr;
00376     stamp= cur->x1;
00377     if (stamp == 0) break;
00378     if (stamp == code && cur->x2 == x) return cur->x3;
00379     addr= (addr + 1) & mask;
00380   }
00381 
00382   lazy_initialize ();
00383   mmx_new_at (cur);
00384   cur->x1= code;
00385   cur->x2= x;
00386   cur->x3= *init;
00387   size++;
00388   return cur->x3;
00389 }

void simplify (  )  [inline]

Definition at line 400 of file new_table.hpp.

References new_table_rep< C, T, V >::lazy_initialize(), and new_table_rep< C, T, V >::resize().

00400                      {
00401   lazy_initialize ();
00402   for (nat i=0; i<n; i++)
00403     if ((a + i)->x3 == *init)
00404       remove (i);
00405   while ((size << 3) < n) resize (n>>1);
00406 }

format<T > tfm (  )  const [inline, inherited]

Definition at line 201 of file type_props.hpp.

00201 { return *this; }

format<C> tfm (  )  const [inline, inherited]

Definition at line 201 of file type_props.hpp.

00201 { return *this; }

format< C > tfm1 (  )  const [inline, inherited]

Definition at line 264 of file type_props.hpp.

00264 { return this->tfm (); }

format< T > tfm2 (  )  const [inline, inherited]

Definition at line 271 of file type_props.hpp.

00271 { return this->tfm (); }


Friends And Related Function Documentation

const C& I ( const new_table< C, T, V > &  t  )  [friend]

Definition at line 232 of file new_table.hpp.

00232                    {
00233   t->lazy_initialize ();
00234   return *t->init;
00235 }

C& I ( new_table< C, T, V > &  t  )  [friend]

Definition at line 226 of file new_table.hpp.

00226              {
00227   t->lazy_initialize ();
00228   return *t->init;
00229 }

nat N ( const new_table< C, T, V > &  t  )  [friend]

Definition at line 244 of file new_table.hpp.

00244                    {
00245   return t->size;
00246 }

friend class new_entries_iterator_rep< C, T, V > [friend]

Definition at line 143 of file new_table.hpp.

friend class new_table< C, T, V > [friend]

Definition at line 142 of file new_table.hpp.

friend class new_table_iterator_rep< C, T, V > [friend]

Definition at line 144 of file new_table.hpp.

bool operator== ( const new_table< C, T, V > &  t1,
const new_table< C, T, V > &  t2 
) [friend]

Definition at line 764 of file new_table.hpp.

00769 { return unary_map<sqrt_op> (t); }

const C& read_I ( const new_table< C, T, V > &  t  )  [friend]

Definition at line 238 of file new_table.hpp.

00238                         {
00239   t->lazy_initialize ();
00240   return *t->init;
00241 }


Member Data Documentation

MMX_ALLOCATORS int ref_count [inherited]

Definition at line 164 of file basix.hpp.


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

Generated on 6 Dec 2012 for basix by  doxygen 1.6.1