The Original CHomP Software
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
chomp::homology::hashedset< element, hashkeys > Class Template Reference

This is a template for a set of objects of the given type. More...

#include <hashsets.h>

Public Types

typedef element value_type
 The type of elements stored in the set. More...
 
typedef hashkeys hashing_method
 The type of hashing. More...
 

Public Member Functions

 hashedset (int_t initialsize=0, int bequiet=1)
 The default constructor for creating an empty set of objects. More...
 
 hashedset (const hashedset< element, hashkeys > &s)
 The copy constructor. More...
 
hashedsetoperator= (const hashedset< element, hashkeys > &s)
 The assignment operator. More...
 
 ~hashedset (void)
 The destructor. More...
 
int_t getnumber (const element &e) const
 Finds the given element and returns its number. More...
 
bool checknum (int_t n) const
 Checks if the given number is an index of some element in the set, that is, if the number is non-negative and strictly smaller than the number of elements in the set. More...
 
bool check (const element &e) const
 Checks if the given element is in the set. More...
 
const element & operator[] (int_t n) const
 Returns the element with the given number from the set. More...
 
const element & get (int_t n) const
 Returns the element with the given number from the set. More...
 
const element & front () const
 Returns the last element in the set. More...
 
const element & top () const
 Returns the last element in the set. More...
 
int_t add (const element &e)
 Adds the given element to the set and returns its number. More...
 
int_t push (const element &e)
 Adds an element to the set (this is an equivalent of 'add'). More...
 
int_t push_back (const element &e)
 Adds an element to the set (this is an equivalent of 'add'). More...
 
int remove (const element &e)
 Removes the given element from the set. More...
 
int removenum (int_t n)
 Returns an element with the given number from the set. More...
 
int_t pop ()
 Removes the last element from the set. More...
 
hashedset< element, hashkeys > & add (const hashedset< element, hashkeys > &s)
 Adds an entire set of elements to the set. More...
 
hashedset< element, hashkeys > & remove (const hashedset< element, hashkeys > &s)
 Removes an entire set of elements from the set. More...
 
int_t size () const
 Returns the number of elements in the set. More...
 
bool empty () const
 Returns true if the set is empty. Otherwise returns false. More...
 
void swap (hashedset< element, hashkeys > &other)
 Swaps two hashed sets by swapping their internal data. More...
 
bool operator== (const hashedset< element, hashkeys > &other) const
 Verifies whether two hashed sets have the same elements. More...
 
void intersection (const hashedset< element, hashkeys > &s1, const hashedset< element, hashkeys > &s2)
 Computes the intersection of two hashed sets and adds the result to the current set. More...
 

Public Attributes

hashstatstat
 Hashed set statistics. More...
 

Private Member Functions

int_t hashfind (const element &e, int_t *addpos=NULL) const
 Finds the position in the hashing table at which the number of the given element should be. More...
 
void rehash (int_t newsize=0)
 Replace the old hashing table with a new one. More...
 

Static Private Member Functions

static bool numberisprime (const int_t &n)
 Verifies whether the given number is prime or not. More...
 
static int_t rounduptoprime (int_t n)
 Rounds up the given number to a prime number. More...
 

Private Attributes

int_t nelem
 The number of elements stored in the set. More...
 
multitable< element > tab
 The table of these elements. More...
 
int hashing
 Is the hashing table in use? More...
 
int_t hashsize
 The size of the hashing table. More...
 
int_t hashcleared
 The number of cleared entries in the hashing table. More...
 
multitable< int_thashtable
 The hashing table. More...
 

Static Private Attributes

static const int_t InitHashSize
 The default initial size of a hashing table. More...
 
static const int_t InitTabSize
 The initial size of a table in a hashed set. More...
 
static const int_t StartHashingSize
 The minimal number of elements above which hashing table is actually used. More...
 

Detailed Description

template<class element, class hashkeys = HashingGlobal<element>>
class chomp::homology::hashedset< element, hashkeys >

This is a template for a set of objects of the given type.

Each of the objects should have two functions for generating hashing keys: "int_t hashkey1 (const object &x)" and "int_t hashkey2 (x)". Note: If you remove elements which are not at the end of the set, then the numbers of other elements can change! In the current solution, the last element is put in place of the removed one, but this behavior may be changed in the future versions of this template.

Definition at line 184 of file hashsets.h.

Member Typedef Documentation

◆ hashing_method

template<class element , class hashkeys = HashingGlobal<element>>
typedef hashkeys chomp::homology::hashedset< element, hashkeys >::hashing_method

The type of hashing.

Definition at line 191 of file hashsets.h.

◆ value_type

template<class element , class hashkeys = HashingGlobal<element>>
typedef element chomp::homology::hashedset< element, hashkeys >::value_type

The type of elements stored in the set.

Definition at line 188 of file hashsets.h.

Constructor & Destructor Documentation

◆ hashedset() [1/2]

template<class element , class hashkeys >
chomp::homology::hashedset< element, hashkeys >::hashedset ( int_t  initialsize = 0,
int  bequiet = 1 
)
explicit

The default constructor for creating an empty set of objects.

If you expect the set to keep a lot of elements, you may want to set the initial size to something large.

Definition at line 355 of file hashsets.h.

355 :
356 nelem (0), tab ((initialsize > 0) ? initialsize :
358 hashing (0),
359 hashsize (initialsize + (initialsize >> 2) + InitHashSize),
361{
363 if (bequiet)
364 stat = NULL;
365 else
366 stat = new hashstat;
367 return;
368} /* hashedset<element,hashkeys>::hashedset */
int_t nelem
The number of elements stored in the set.
Definition: hashsets.h:302
int hashing
Is the hashing table in use?
Definition: hashsets.h:308
static const int_t InitTabSize
The initial size of a table in a hashed set.
Definition: hashsets.h:292
static int_t rounduptoprime(int_t n)
Rounds up the given number to a prime number.
Definition: hashsets.h:798
multitable< element > tab
The table of these elements.
Definition: hashsets.h:305
multitable< int_t > hashtable
The hashing table.
Definition: hashsets.h:318
hashstat * stat
Hashed set statistics.
Definition: hashsets.h:285
static const int_t InitHashSize
The default initial size of a hashing table.
Definition: hashsets.h:289
int_t hashcleared
The number of cleared entries in the hashing table.
Definition: hashsets.h:314
int_t hashsize
The size of the hashing table.
Definition: hashsets.h:311
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115

References chomp::homology::hashedset< element, hashkeys >::hashsize, chomp::homology::hashedset< element, hashkeys >::rounduptoprime(), and chomp::homology::hashedset< element, hashkeys >::stat.

◆ hashedset() [2/2]

template<class element , class hashkeys >
chomp::homology::hashedset< element, hashkeys >::hashedset ( const hashedset< element, hashkeys > &  s)

The copy constructor.

Definition at line 371 of file hashsets.h.

371 :
372 nelem (s. nelem), tab (s. tab),
373 hashing (s. hashing), hashsize (s. hashsize),
375{
376 if (s. stat)
377 stat = new hashstat;
378 else
379 stat = NULL;
380 return;
381} /* hashedset<element,hashkeys>::hashedset */

References chomp::homology::hashedset< element, hashkeys >::stat.

◆ ~hashedset()

template<class element , class hashkeys >
chomp::homology::hashedset< element, hashkeys >::~hashedset ( void  )

The destructor.

Definition at line 403 of file hashsets.h.

404{
405 if (!stat)
406 return;
407 sout << " " << *stat << '\n';
408 delete stat;
409 stat = NULL;
410 return;
411} /* hashedset<element,hashkeys>::~hashedset */
outputstream sout
A replacement for standard output stream, with optional logging and other features provided by the cl...

References chomp::homology::sout.

Member Function Documentation

◆ add() [1/2]

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::add ( const element &  e)

Adds the given element to the set and returns its number.

If the element was already in the set, it is not added the second time, only its number is returned.

Definition at line 471 of file hashsets.h.

472{
473 if (!hashing)
474 {
475 for (int_t i = 0; i < nelem; ++ i)
476 {
477 if (tab (i) == e)
478 return i;
479 }
480 tab [nelem ++] = e;
481 if (nelem >= StartHashingSize)
482 {
483 hashing = 1;
484 rehash ();
485 }
486 return (nelem - 1);
487 }
488
489 // rehash if there is very little free space in the hashing table
490 if (hashsize - hashcleared < nelem + (nelem >> 1) + 19)
491 rehash ();
492
493 // find the position of the element's number in the hashing table
494 int_t addpos = -1;
495 int_t pos = hashfind (e, &addpos);
496
497 // if it alread was in the set, then just return its number
498 if (hashtable (pos) >= 0)
499 return hashtable (pos);
500
501 // add this element to the set and return its new number
502 if (addpos >= 0)
503 pos = addpos;
504 hashtable [pos] = nelem;
505 tab [nelem] = e;
506 return nelem ++;
507} /* hashedset<element,hashkeys>::add */
static const int_t StartHashingSize
The minimal number of elements above which hashing table is actually used.
Definition: hashsets.h:299
void rehash(int_t newsize=0)
Replace the old hashing table with a new one.
Definition: hashsets.h:737
int_t hashfind(const element &e, int_t *addpos=NULL) const
Finds the position in the hashing table at which the number of the given element should be.
Definition: hashsets.h:692

◆ add() [2/2]

template<class element , class hashkeys >
hashedset< element, hashkeys > & chomp::homology::hashedset< element, hashkeys >::add ( const hashedset< element, hashkeys > &  s)

Adds an entire set of elements to the set.

Definition at line 596 of file hashsets.h.

597{
598 int_t n = s. size ();
599 for (int_t i = 0; i < n; ++ i)
600 add (s [i]);
601 return *this;
602} /* hashedset<element,hashkeys>::add */
int_t size() const
Returns the number of elements in the set.
Definition: hashsets.h:631
int_t add(const element &e)
Adds the given element to the set and returns its number.
Definition: hashsets.h:471

◆ check()

template<class element , class hashkeys >
bool chomp::homology::hashedset< element, hashkeys >::check ( const element &  e) const
inline

Checks if the given element is in the set.

Returns true if yes, false if no.

Definition at line 439 of file hashsets.h.

440{
441 return (getnumber (e) >= 0);
442} /* hashedset<element,hashkeys>::check */
int_t getnumber(const element &e) const
Finds the given element and returns its number.
Definition: hashsets.h:414

◆ checknum()

template<class element , class hashkeys >
bool chomp::homology::hashedset< element, hashkeys >::checknum ( int_t  n) const
inline

Checks if the given number is an index of some element in the set, that is, if the number is non-negative and strictly smaller than the number of elements in the set.

Returns true if yes, false if no.

Definition at line 433 of file hashsets.h.

434{
435 return ((n >= 0) && (n < nelem));
436} /* hashedset<element,hashkeys>::checknum */

◆ empty()

template<class element , class hashkeys >
bool chomp::homology::hashedset< element, hashkeys >::empty
inline

Returns true if the set is empty. Otherwise returns false.

Definition at line 625 of file hashsets.h.

626{
627 return !nelem;
628} /* hashedset<element,hashkeys>::empty */

◆ front()

template<class element , class hashkeys >
const element & chomp::homology::hashedset< element, hashkeys >::front
inline

Returns the last element in the set.

Definition at line 459 of file hashsets.h.

460{
461 return get (nelem - 1);
462} /* hashedset<element,hashkeys>::front */
const element & get(int_t n) const
Returns the element with the given number from the set.
Definition: hashsets.h:445

◆ get()

template<class element , class hashkeys >
const element & chomp::homology::hashedset< element, hashkeys >::get ( int_t  n) const
inline

Returns the element with the given number from the set.

Definition at line 445 of file hashsets.h.

446{
447 if ((n < 0) || (n >= nelem))
448 throw "Trying to get an element out of range.";
449 return tab (n);
450} /* hashedset<element,hashkeys>::get */

◆ getnumber()

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::getnumber ( const element &  e) const

Finds the given element and returns its number.

Returns -1 if the element is not in the set.

Definition at line 414 of file hashsets.h.

415{
416 if (hashing)
417 {
418 int_t pos = hashfind (e);
419 return (hashtable (pos));
420 }
421 else
422 {
423 for (int_t i = 0; i < nelem; ++ i)
424 {
425 if (tab (i) == e)
426 return i;
427 }
428 return -1;
429 }
430} /* hashedset<element,hashkeys>::getnumber */

◆ hashfind()

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::hashfind ( const element &  e,
int_t addpos = NULL 
) const
private

Finds the position in the hashing table at which the number of the given element should be.

If there is -1 there, then the number's element should be written there if adding. Saves to 'addposition' the first cleared position in the hashing table if found or sets it to -1 otherwise.

Definition at line 692 of file hashsets.h.

693{
694 if (!hashing)
695 throw "Hashing is turned off.";
696
697 int_t key = hashkey1 (e);
698 if (key < 0)
699 key = -(key + 1);
700 int_t pos = key % hashsize;
701 if (addpos)
702 *addpos = -1;
703
704 // start updating hashing statistics
705 if (stat)
706 ++ (stat -> hashhits);
707
708 // find the position of the element in the hashing table
709 int_t number;
710 int_t add = 0;
711 while ((number = hashtable (pos)) != -1)
712 {
713 if ((number >= 0) && (e == tab (number)))
714 return (pos);
715 if (addpos && (*addpos < 0) && (number == -2))
716 *addpos = pos;
717 if (!add)
718 {
719 int_t key = hashkey2 (e);
720 if (key < 0)
721 key = -(key + 1);
722 add = key % (hashsize - 1) + 1;
723 }
724 pos += add;
725 if (pos >= hashsize)
726 pos -= hashsize;
727 if (stat)
728 ++ (stat -> hashmisses);
729 }
730
731 // return the position located in the hashing table
732 return (pos);
733
734} /* hashedset<element,hashkeys>::hashfind */
int_t hashkey2(const hashNumber< Number > &n)
The second hashing key.
Definition: bincube.h:1036
int_t hashkey1(const hashNumber< Number > &n)
The first hashing key.
Definition: bincube.h:1029

References chomp::homology::hashkey1(), and chomp::homology::hashkey2().

◆ intersection()

template<class element , class hashkeys >
void chomp::homology::hashedset< element, hashkeys >::intersection ( const hashedset< element, hashkeys > &  s1,
const hashedset< element, hashkeys > &  s2 
)
inline

Computes the intersection of two hashed sets and adds the result to the current set.

Definition at line 664 of file hashsets.h.

666{
667 int_t size1 = s1. size ();
668 int_t size2 = s2. size ();
669
670 if (size1 <= size2)
671 {
672 for (int_t i = 0; i < size1; ++ i)
673 {
674 const element &elem = s1. tab [i];
675 if (s2. check (elem))
676 this -> add (elem);
677 }
678 }
679 else
680 {
681 for (int_t i = 0; i < size2; ++ i)
682 {
683 const element &elem = s2. tab [i];
684 if (s1. check (elem))
685 this -> add (elem);
686 }
687 }
688 return;
689} /* hashedset<element,hashkeys>::intersection */
bool check(const element &e) const
Checks if the given element is in the set.
Definition: hashsets.h:439

◆ numberisprime()

template<class element , class hashkeys >
bool chomp::homology::hashedset< element, hashkeys >::numberisprime ( const int_t n)
inlinestaticprivate

Verifies whether the given number is prime or not.

Note: This procedure is quite inefficient for large numbers.

Definition at line 781 of file hashsets.h.

782{
783 if (n < 2)
784 return 0;
785
786 int_t i = 2;
787 while (i * i <= n)
788 {
789 if (!(n % i))
790 return false;
791 ++ i;
792 }
793
794 return true;
795} /* hashedset<element,hashkeys>::numberisprime */

◆ operator=()

template<class element , class hashkeys >
hashedset< element, hashkeys > & chomp::homology::hashedset< element, hashkeys >::operator= ( const hashedset< element, hashkeys > &  s)

The assignment operator.

Definition at line 384 of file hashsets.h.

386{
387 if (this == &s)
388 return *this;
389
390 if (s. stat)
391 stat = new hashstat (*stat);
392 nelem = s. nelem;
393 tab = s. tab;
394 hashing = s. hashing;
395 hashsize = s. hashsize;
397 hashtable = s. hashtable;
398
399 return *this;
400} /* multitable<element,hashkeys>::operator = */

◆ operator==()

template<class element , class hashkeys >
bool chomp::homology::hashedset< element, hashkeys >::operator== ( const hashedset< element, hashkeys > &  other) const
inline

Verifies whether two hashed sets have the same elements.

Uses the standard comparison operator for the elements.

Definition at line 650 of file hashsets.h.

652{
653 if (this -> nelem != other. nelem)
654 return false;
655 for (int_t i = 0; i < nelem; ++ i)
656 {
657 if (!other. check (this -> tab [i]))
658 return false;
659 }
660 return true;
661} /* hashedset<element,hashkeys>::swap */

◆ operator[]()

template<class element , class hashkeys >
const element & chomp::homology::hashedset< element, hashkeys >::operator[] ( int_t  n) const
inline

Returns the element with the given number from the set.

Definition at line 453 of file hashsets.h.

454{
455 return get (n);
456} /* hashedset<element,hashkeys>::operator [] */

◆ pop()

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::pop
inline

Removes the last element from the set.

Throws an exception if the set is empty.

Definition at line 588 of file hashsets.h.

589{
590 if (!nelem)
591 throw "Trying to remove an element from an empty set.";
592 return removenum (nelem - 1);
593} /* hashedset<element,hashkeys>::pop */
int removenum(int_t n)
Returns an element with the given number from the set.
Definition: hashsets.h:573

◆ push()

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::push ( const element &  e)
inline

Adds an element to the set (this is an equivalent of 'add').

Definition at line 510 of file hashsets.h.

511{
512 return add (e);
513} /* hashedset<element,hashkeys>::push */

◆ push_back()

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::push_back ( const element &  e)
inline

Adds an element to the set (this is an equivalent of 'add').

Definition at line 516 of file hashsets.h.

517{
518 return add (e);
519} /* hashedset<element,hashkeys>::push_back */

◆ rehash()

template<class element , class hashkeys >
void chomp::homology::hashedset< element, hashkeys >::rehash ( int_t  newsize = 0)
private

Replace the old hashing table with a new one.

The desired size may be given, otherwise an optimal size is determined and the table is made larger or smaller.

Definition at line 737 of file hashsets.h.

738{
739 if (stat)
740 ++ (stat -> rehashcount);
741
742 // adjust the new size of the hashing table
743 if ((newsize < (nelem << 1) + InitHashSize) ||
744 (newsize > (nelem << 2) + InitHashSize))
745 newsize = (nelem << 1) + nelem + InitHashSize;
746
747 // DEBUG
748// sbug << "(rehash: nelem=" << nelem <<
749// ", hashsize=" << hashsize << ", newsize=" << newsize << ")\n";
750
751 // check if it is not too large for 16-bit programs
752 int_t x = 0xFFFF;
753 if ((x < 0) && (newsize >= 16384))
754 throw "Set too large for this 16-bit program.";
755
756 // free unused memory if desired
757 if (newsize < hashsize)
758 {
759 multitable<int_t> empty;
761 }
762
763 // set the new value of the hashing table and re-buid it
765 hashcleared = 0;
766
767 // build the entire hash table from the beginning
768 hashtable. fill (-1, hashsize);
769 for (int_t i = 0; i < nelem; ++ i)
770 {
771 int_t pos = hashfind (tab (i));
772 if (hashtable (pos) != -1)
773 throw "A repeated element in a set!";
774 hashtable [pos] = i;
775 }
776
777 return;
778} /* hashedset<element,hashkeys>::rehash */
bool empty() const
Returns true if the set is empty. Otherwise returns false.
Definition: hashsets.h:625

References chomp::homology::hashedset< element, hashkeys >::rounduptoprime().

◆ remove() [1/2]

template<class element , class hashkeys >
int chomp::homology::hashedset< element, hashkeys >::remove ( const element &  e)

Removes the given element from the set.

Returns 0 if successful, -1 if the element was not in the set.

Definition at line 522 of file hashsets.h.

523{
524 if (!hashing)
525 {
526 for (int_t i = 0; i < nelem; ++ i)
527 {
528 if (tab (i) == e)
529 {
530 tab [i] = tab (-- nelem);
531 return 0;
532 }
533 }
534 return -1;
535 }
536
537 // find the position in the hashing table with this element's number
538 int_t pos = hashfind (e);
539
540 // if it was not there, then finish
541 if (hashtable (pos) < 0)
542 return -1;
543 int_t n = hashtable (pos);
544
545 // update the hashing table and the number of elements in the set
546 hashtable [pos] = -2;
547 -- nelem;
548 ++ hashcleared;
549
550 // if it was not the last element in the set, move the last one
551 // to the vacated place
552 if (n != nelem)
553 {
554 pos = hashfind (tab (nelem));
555 hashtable [pos] = n;
556 tab [n] = tab (nelem);
557 }
558
559 // if there are very few elements in the table, turn off hashing
560 if (nelem < StartHashingSize / 2)
561 {
562 hashing = 0;
563 }
564
565 // if there are very many cleared entries, then rehash
566 else if (hashcleared > nelem + 19)
567 rehash ();
568
569 return 0;
570} /* hashedset<element,hashkeys>::remove */

◆ remove() [2/2]

template<class element , class hashkeys >
hashedset< element, hashkeys > & chomp::homology::hashedset< element, hashkeys >::remove ( const hashedset< element, hashkeys > &  s)

Removes an entire set of elements from the set.

Definition at line 605 of file hashsets.h.

606{
607 if (this -> size () < s. size ())
608 {
609 for (int_t i = 0; i < this -> size (); ++ i)
610 {
611 if (s. check ((*this) [i]))
612 this -> removenum (i --);
613 }
614 }
615 else
616 {
617 int_t n = s. size ();
618 for (int_t i = 0; i < n; ++ i)
619 remove (s [i]);
620 }
621 return *this;
622} /* hashedset<element,hashkeys>::remove */
int remove(const element &e)
Removes the given element from the set.
Definition: hashsets.h:522

◆ removenum()

template<class element , class hashkeys >
int chomp::homology::hashedset< element, hashkeys >::removenum ( int_t  n)
inline

Returns an element with the given number from the set.

Returns 0 if successful, -1 if the number is out of range.

Definition at line 573 of file hashsets.h.

574{
575 if ((n < 0) || (n >= nelem))
576 return -1;
577 if (!hashing)
578 {
579 -- nelem;
580 if (n != nelem)
581 tab [n] = tab (nelem);
582 return 0;
583 }
584 return remove (tab (n));
585} /* hashedset<element,hashkeys>::removenum */

◆ rounduptoprime()

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::rounduptoprime ( int_t  n)
staticprivate

Rounds up the given number to a prime number.

Definition at line 798 of file hashsets.h.

799{
801 ++ n;
802
803 return n;
804} /* hashedset<element,hashkeys>::rounduptoprime */
static bool numberisprime(const int_t &n)
Verifies whether the given number is prime or not.
Definition: hashsets.h:781

Referenced by chomp::homology::hashedset< element, hashkeys >::hashedset(), and chomp::homology::hashedset< element, hashkeys >::rehash().

◆ size()

template<class element , class hashkeys >
int_t chomp::homology::hashedset< element, hashkeys >::size
inline

Returns the number of elements in the set.

Definition at line 631 of file hashsets.h.

632{
633 return nelem;
634} /* hashedset<element,hashkeys>::size */

◆ swap()

template<class element , class hashkeys >
void chomp::homology::hashedset< element, hashkeys >::swap ( hashedset< element, hashkeys > &  other)
inline

Swaps two hashed sets by swapping their internal data.

Definition at line 637 of file hashsets.h.

638{
639 std::swap (stat, other. stat);
640 std::swap (nelem, other. nelem);
641 tab. swap (other. tab);
642 std::swap (hashing, other. hashing);
643 std::swap (hashsize, other. hashsize);
645 hashtable. swap (other. hashtable);
646 return;
647} /* hashedset<element,hashkeys>::swap */
void swap(hashedset< element, hashkeys > &other)
Swaps two hashed sets by swapping their internal data.
Definition: hashsets.h:637
void swap(mwWorkerData &data1, mwWorkerData &data2)
Definition: mwcoord.h:108

References chomp::multiwork::swap().

◆ top()

template<class element , class hashkeys >
const element & chomp::homology::hashedset< element, hashkeys >::top
inline

Returns the last element in the set.

Definition at line 465 of file hashsets.h.

466{
467 return get (nelem - 1);
468} /* hashedset<element,hashkeys>::top */

Member Data Documentation

◆ hashcleared

template<class element , class hashkeys = HashingGlobal<element>>
int_t chomp::homology::hashedset< element, hashkeys >::hashcleared
private

The number of cleared entries in the hashing table.

Definition at line 314 of file hashsets.h.

◆ hashing

template<class element , class hashkeys = HashingGlobal<element>>
int chomp::homology::hashedset< element, hashkeys >::hashing
private

Is the hashing table in use?

Definition at line 308 of file hashsets.h.

◆ hashsize

template<class element , class hashkeys = HashingGlobal<element>>
int_t chomp::homology::hashedset< element, hashkeys >::hashsize
private

The size of the hashing table.

Definition at line 311 of file hashsets.h.

Referenced by chomp::homology::hashedset< element, hashkeys >::hashedset().

◆ hashtable

template<class element , class hashkeys = HashingGlobal<element>>
multitable<int_t> chomp::homology::hashedset< element, hashkeys >::hashtable
private

The hashing table.

Each entry contains the index of the element in the set, or -1 if the entry is free, or -2 if it was cleared.

Definition at line 318 of file hashsets.h.

◆ InitHashSize

template<class element , class hashkeys >
const int_t chomp::homology::hashedset< element, hashkeys >::InitHashSize
staticprivate

The default initial size of a hashing table.

Definition at line 289 of file hashsets.h.

◆ InitTabSize

template<class element , class hashkeys >
const int_t chomp::homology::hashedset< element, hashkeys >::InitTabSize
staticprivate

The initial size of a table in a hashed set.

Definition at line 292 of file hashsets.h.

◆ nelem

template<class element , class hashkeys = HashingGlobal<element>>
int_t chomp::homology::hashedset< element, hashkeys >::nelem
private

The number of elements stored in the set.

Definition at line 302 of file hashsets.h.

◆ StartHashingSize

template<class element , class hashkeys >
const int_t chomp::homology::hashedset< element, hashkeys >::StartHashingSize
staticprivate

The minimal number of elements above which hashing table is actually used.

If the number of elements is below this threshold, then a simple array is used and elements are searched for by going through all the elements of the array.

Definition at line 299 of file hashsets.h.

◆ stat

template<class element , class hashkeys = HashingGlobal<element>>
hashstat* chomp::homology::hashedset< element, hashkeys >::stat

Hashed set statistics.

Allocate this structure to make the set gather usage and effectiveness statistics. By default this pointer is set to 0. It is deallocated in the destructor.

Definition at line 285 of file hashsets.h.

Referenced by chomp::homology::hashedset< element, hashkeys >::hashedset().

◆ tab

template<class element , class hashkeys = HashingGlobal<element>>
multitable<element> chomp::homology::hashedset< element, hashkeys >::tab
private

The table of these elements.

Definition at line 305 of file hashsets.h.


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