Index

NAME

IndexSetUnion - index set, union of index sets


INCLUDE

include "IndexSetUnion.h"

SYNTAX

 //-----------------------------------------------------------------------------
 class IndexSetUnion: public IndexSet
 //-----------------------------------------------------------------------------
 {
 private:

   VecSimplest(Handle(IndexSet)) table;
   int no_of_sets;
   int curr_it_set;

   protected :

   virtual void specialStartIterator ();
   virtual void specialReverseStartIterator ();

   virtual void computeNoIndices ();

   virtual int getLineNumber (const Ptv(int)& /*pt*/) const {
     DBP("IndexSetUnion::getLineNumber not implemented");
     return 0;
   }

 public :

   IndexSetUnion ();
   IndexSetUnion (int maxNoSets);
   IndexSetUnion (const IndexSetUnion& b);
   IndexSetUnion (const IndexSet_prm& pm);
  ~IndexSetUnion ();

   IndexSetUnion& operator=(const IndexSetUnion& b);

   bool redim(int maxNoSets);

   // IndexSet number i is returned
   IndexSet& getIndexSet(int i);
   const IndexSet& getIndexSet(int i) const;

   int getNoSets() const;

   virtual IndexSetType getIndexSetType () const;

   // use with care if second argument is set to false
   void add    (const IndexSet& ind, bool allocate = true);
   void grow   (int n);
   void remove (int n);

   // get new index line :
   virtual void specialIterate ();
   virtual void specialReverseIterate ();

   virtual void getIndexIterator (Handle(IndexSet)& I) const;
   virtual void print (Os os) const;
   virtual void scan  (Is is);

   CLASS_INFO

   VIRTUAL_CAST(IndexSetUnion)

 };



KEYWORDS

index set, iterator, union of index sets



DESCRIPTION

The  class  implements an index set by a table of objects of type
IndexSet.  The class is itself derived  from  the  abstract  base
class  IndexSet.  This  means  that any index set in the IndexSet
hierarchy can be put into the table. The class defines  an  index
set  as  the  union  of  the index sets within this table. During
iteration the index sets of the table are iterated  sequentially.
This  means  that  an  index  might be defined twize as it is not
encountered for intersecton.


CONSTRUCTORS AND INITIALIZATION

The constructor with an integer argument  specifies  the  maximum
number of IndexSet objects contained by the class. The add member
function can be used to initialize the index sets.



MEMBER FUNCTIONS

Please note that the inherited member functions  from  the  class
IndexSet are described  within the documentation of IndexSet.



bool  redim  -  redimensions  the  number of index set (the table
length), the previous contents of the table is deallocated.

add - add an index set to the table, note  that  as  default  the
reference  given as argument is copied to a new object within the
class by calling  the  getIndexIterator  member  function.   This
should  always  be done if IndexSetUnion are not the only user of
the specific IndexSet. If the second argument is set to false the
address  of  the  object  is  rebinded  to the datastructure. The
object must thus not be used elsewhere and the object should have
been  allocated dynamically. The proper deallocation is then per­
formed by the class IndexSetUnion.

grow - The table containing the index sets are enlarged with  the
given integer number of sets. The contense is preserved.

remove  -  The table containing the index sets are shortened with
the given integer number of sets. The  remaining  sets  are  pre­
served.

scan  -  The  format read by scan is same as written by the print
member function. This is also the format read by the scan of  the
class IndexSet_prm.  See the example below.





EXAMPLES

| #include <IndexSetUnion.h>
#include <IndexSetBox.h>

void main()
{

  The index set we want to construct :
    12        xxxx
    11        xxxx
    10        xxxx
    9         xxxx
    8     xxxxxxxxxxxx
    7     xxxxxxxxxxxx
    6     xxxxxxxxxxxx
    5     xxxxxxxxxxxx
    4         xxxx
    3         xxxx
    2         xxxx
    1         xxxx
          ------------
          123456789111
                   012


 IndexSetUnion  ind(3);  // makes a table for three IndexSet ele­
ments.
 IndexSetBox   box(2);

 box.scan("(5,1) (8,4)");    ind.add(box);
 box.scan("(1,5) (12,8)");   ind.add(box);
 box.scan("(5,9) (8,12)");   ind.add(box);

 s_o << ind << "0;
 IndexSet_prm prm;
 prm.scan(s_i);
 IndexSetIndieces ind2 (prm);
 ind2.print(s_o);


//  To  initialize  the  parameter  class  the following input is
needed :
//
-----------------------------------------------------------------
>index_set_storage = IndexSetUnion
>nsd = 2
>index_set_string = {
>no_of_sets = 3
>index_set_storage  =  IndexSetBox >nsd = 2 >index_set_string = {
(1,1)x(4,4) }
>index_set_storage  =  IndexSetBox >nsd = 2 >index_set_string = {
(1,5)x(12,8) }
>index_set_storage  =  IndexSetBox >nsd = 2 >index_set_string = {
(5,9)x(8,12) }
                     }



SEE ALSO

class  IndexSet,  class  IndexSetBox,  class  IndexSetBoxItOrder,
class ArrayGenSel(Type).


DEVELOPED BY

Numerical Objects AS


AUTHOR

Are Magnus Bruaset, Numerical Objects AS