00001
00002
00003 #ifndef DUNE_INDEXSET_HH
00004 #define DUNE_INDEXSET_HH
00005
00006 #include <algorithm>
00007 #include <dune/common/arraylist.hh>
00008 #include <dune/common/exceptions.hh>
00009 #include <dune/common/unused.hh>
00010 #include <iostream>
00011
00012 #include "localindex.hh"
00013
00014 #include <stdint.h>
00015
00016 namespace Dune
00017 {
00027
00028
00029 template<class TG, class TL>
00030 class IndexPair;
00031
00037 template<class TG, class TL>
00038 std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair);
00039
00040 template<class TG, class TL>
00041 bool operator==(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00042
00043 template<class TG, class TL>
00044 bool operator!=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00045
00046 template<class TG, class TL>
00047 bool operator<(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00048
00049 template<class TG, class TL>
00050 bool operator>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00051
00052 template<class TG, class TL>
00053 bool operator<=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00054
00055 template<class TG, class TL>
00056 bool operator >=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00057
00058 template<class TG, class TL>
00059 bool operator==(const IndexPair<TG,TL>&, const TG&);
00060
00061 template<class TG, class TL>
00062 bool operator!=(const IndexPair<TG,TL>&, const TG&);
00063
00064 template<class TG, class TL>
00065 bool operator<(const IndexPair<TG,TL>&, const TG&);
00066
00067 template<class TG, class TL>
00068 bool operator>(const IndexPair<TG,TL>&, const TG&);
00069
00070 template<class TG, class TL>
00071 bool operator<=(const IndexPair<TG,TL>&, const TG&);
00072
00073 template<class TG, class TL>
00074 bool operator >=(const IndexPair<TG,TL>&, const TG&);
00075
00076 template<typename T>
00077 struct MPITraits;
00078
00082 template<class TG, class TL>
00083 class IndexPair
00084 {
00085 friend std::ostream& operator<<<>(std::ostream&, const IndexPair<TG,TL>&);
00086 friend bool operator==<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00087 friend bool operator!=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00088 friend bool operator< <>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00089 friend bool operator><>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00090 friend bool operator<=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00091 friend bool operator>=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
00092 friend bool operator==<>(const IndexPair<TG,TL>&, const TG &);
00093 friend bool operator!=<>(const IndexPair<TG,TL>&, const TG &);
00094 friend bool operator< <>(const IndexPair<TG,TL>&, const TG &);
00095 friend bool operator> <>(const IndexPair<TG,TL>&, const TG &);
00096 friend bool operator<=<>(const IndexPair<TG,TL>&, const TG &);
00097 friend bool operator>=<>(const IndexPair<TG,TL>&, const TG &);
00098 friend struct MPITraits<IndexPair<TG,TL> >;
00099
00100 public:
00106 typedef TG GlobalIndex;
00107
00119 typedef TL LocalIndex;
00120
00127 IndexPair(const GlobalIndex& global, const LocalIndex& local);
00128
00132 IndexPair();
00139 IndexPair(const GlobalIndex& global);
00140
00146 inline const GlobalIndex& global() const;
00147
00153 inline LocalIndex& local();
00154
00160 inline const LocalIndex& local() const;
00161
00167 inline void setLocal(int index);
00168 private:
00170 GlobalIndex global_;
00172 LocalIndex local_;
00173 };
00174
00179 enum ParallelIndexSetState
00180 {
00185 GROUND,
00189 RESIZE
00199 };
00200
00204 class InvalidIndexSetState : public InvalidStateException {};
00205
00206
00207 template<class I> class GlobalLookupIndexSet;
00208
00215 template<typename TG, typename TL, int N=100>
00216 class ParallelIndexSet
00217 {
00218 friend class GlobalLookupIndexSet<ParallelIndexSet<TG,TL,N> >;
00219
00220 public:
00225 typedef TG GlobalIndex;
00226
00238 typedef TL LocalIndex;
00239
00243 typedef Dune::IndexPair<GlobalIndex,LocalIndex> IndexPair;
00244
00245 enum {
00252 arraySize= (N>0) ? N : 1
00253 };
00254
00256 class iterator :
00257 public ArrayList<IndexPair,N>::iterator
00258 {
00259 typedef typename ArrayList<IndexPair,N>::iterator
00260 Father;
00261 friend class ParallelIndexSet<GlobalIndex,LocalIndex,N>;
00262 public:
00263 iterator(ParallelIndexSet<TG,TL,N>& indexSet, const Father& father)
00264 : Father(father), indexSet_(&indexSet)
00265 {}
00266
00267 iterator(const iterator& other)
00268 : Father(other), indexSet_(other.indexSet_)
00269 {}
00270
00271 iterator& operator==(const iterator& other)
00272 {
00273 Father::operator==(other);
00274 indexSet_ = other.indexSet_;
00275 }
00276
00277 private:
00285 inline void markAsDeleted() const throw(InvalidIndexSetState)
00286 {
00287 #ifndef NDEBUG
00288 if(indexSet_->state_ != RESIZE)
00289 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
00290 <<"while in RESIZE state!");
00291 #endif
00292 Father::operator*().local().setState(DELETED);
00293 }
00294
00296 ParallelIndexSet<TG,TL,N>* indexSet_;
00297
00298 };
00299
00300
00301
00303 typedef typename
00304 ArrayList<IndexPair,N>::const_iterator
00305 const_iterator;
00306
00310 ParallelIndexSet();
00311
00316 inline const ParallelIndexSetState& state()
00317 {
00318 return state_;
00319 }
00320
00326 void beginResize() throw(InvalidIndexSetState);
00327
00336 inline void add(const GlobalIndex& global) throw(InvalidIndexSetState);
00337
00346 inline void add(const GlobalIndex& global, const LocalIndex& local)
00347 throw(InvalidIndexSetState);
00348
00356 inline void markAsDeleted(const iterator& position)
00357 throw(InvalidIndexSetState);
00358
00371 void endResize() throw(InvalidIndexSetState);
00372
00383 inline IndexPair&
00384 operator[](const GlobalIndex& global);
00385
00395 inline IndexPair&
00396 at(const GlobalIndex& global);
00397
00408 inline const IndexPair&
00409 operator[](const GlobalIndex& global) const;
00410
00420 inline const IndexPair&
00421 at(const GlobalIndex& global) const;
00422
00427 inline iterator begin();
00428
00433 inline iterator end();
00434
00439 inline const_iterator begin() const;
00440
00445 inline const_iterator end() const;
00446
00456 inline void renumberLocal();
00457
00464 inline int seqNo() const;
00465
00470 inline size_t size() const;
00471
00472 private:
00474 ArrayList<IndexPair,N> localIndices_;
00476 ArrayList<IndexPair,N> newIndices_;
00478 ParallelIndexSetState state_;
00480 int seqNo_;
00482 bool deletedEntries_;
00487 inline void merge();
00488 };
00489
00490
00496 template<class TG, class TL, int N>
00497 std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet);
00498
00504 template<class I>
00505 class GlobalLookupIndexSet
00506 {
00507 public:
00511 typedef I ParallelIndexSet;
00512
00516 typedef typename ParallelIndexSet::LocalIndex LocalIndex;
00517
00521 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex;
00522
00526 typedef typename ParallelIndexSet::const_iterator const_iterator;
00527
00528 typedef Dune::IndexPair<typename I::GlobalIndex, typename I::LocalIndex> IndexPair;
00529
00536 GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size);
00537
00543 GlobalLookupIndexSet(const ParallelIndexSet& indexset);
00544
00548 ~GlobalLookupIndexSet();
00549
00559 inline const IndexPair&
00560 operator[](const GlobalIndex& global) const;
00561
00565 inline const IndexPair*
00566 pair(const std::size_t& local) const;
00567
00572 inline const_iterator begin() const;
00573
00578 inline const_iterator end() const;
00579
00586 inline int seqNo() const;
00587
00592 inline size_t size() const;
00593 private:
00597 const ParallelIndexSet& indexSet_;
00598
00602 std::size_t size_;
00603
00607 std::vector<const IndexPair*> indices_;
00608
00609 };
00610
00611
00612 template<typename T>
00613 struct LocalIndexComparator
00614 {
00615 static bool compare(const T& t1, const T& t2){
00616 DUNE_UNUSED_PARAMETER(t1);
00617 DUNE_UNUSED_PARAMETER(t2);
00618 return false;
00619 }
00620 };
00621
00622 template<class TG, class TL>
00623 struct IndexSetSortFunctor
00624 {
00625 bool operator()(const IndexPair<TG,TL>& i1, const IndexPair<TG,TL>& i2)
00626 {
00627 return i1.global()<i2.global() || (i1.global()==i2.global() &&
00628 LocalIndexComparator<TL>::compare(i1.local(),
00629 i2.local()));
00630 }
00631 };
00632
00633
00634
00635 template<class TG, class TL>
00636 inline std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair)
00637 {
00638 os<<"{global="<<pair.global_<<", local="<<pair.local_<<"}";
00639 return os;
00640 }
00641
00642 template<class TG, class TL, int N>
00643 inline std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet)
00644 {
00645 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iterator;
00646 Iterator end = indexSet.end();
00647 os<<"{";
00648 for(Iterator index = indexSet.begin(); index != end; ++index)
00649 os<<*index<<" ";
00650 os<<"}";
00651 return os;
00652
00653 }
00654
00655 template<class TG, class TL>
00656 inline bool operator==(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
00657 {
00658 return a.global_==b.global_;
00659 }
00660
00661 template<class TG, class TL>
00662 inline bool operator!=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
00663 {
00664 return a.global_!=b.global_;
00665 }
00666
00667 template<class TG, class TL>
00668 inline bool operator<(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
00669 {
00670 return a.global_<b.global_;
00671 }
00672
00673 template<class TG, class TL>
00674 inline bool operator>(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
00675 {
00676 return a.global_>b.global_;
00677 }
00678
00679 template<class TG, class TL>
00680 inline bool operator<=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
00681 {
00682 return a.global_<=b.global_;
00683 }
00684
00685 template<class TG, class TL>
00686 inline bool operator >=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
00687 {
00688 return a.global_>=b.global_;
00689 }
00690
00691 template<class TG, class TL>
00692 inline bool operator==(const IndexPair<TG,TL>& a, const TG& b)
00693 {
00694 return a.global_==b;
00695 }
00696
00697 template<class TG, class TL>
00698 inline bool operator!=(const IndexPair<TG,TL>& a, const TG& b)
00699 {
00700 return a.global_!=b;
00701 }
00702
00703 template<class TG, class TL>
00704 inline bool operator<(const IndexPair<TG,TL>& a, const TG& b)
00705 {
00706 return a.global_<b;
00707 }
00708
00709 template<class TG, class TL>
00710 inline bool operator>(const IndexPair<TG,TL>& a, const TG& b)
00711 {
00712 return a.global_>b;
00713 }
00714
00715 template<class TG, class TL>
00716 inline bool operator<=(const IndexPair<TG,TL>& a, const TG& b)
00717 {
00718 return a.global_<=b;
00719 }
00720
00721 template<class TG, class TL>
00722 inline bool operator >=(const IndexPair<TG,TL>& a, const TG& b)
00723 {
00724 return a.global_>=b;
00725 }
00726
00727 #ifndef DOXYGEN
00728
00729 template<class TG, class TL>
00730 IndexPair<TG,TL>::IndexPair(const TG& global, const TL& local)
00731 : global_(global), local_(local){}
00732
00733 template<class TG, class TL>
00734 IndexPair<TG,TL>::IndexPair(const TG& global)
00735 : global_(global), local_(){}
00736
00737 template<class TG, class TL>
00738 IndexPair<TG,TL>::IndexPair()
00739 : global_(), local_(){}
00740
00741 template<class TG, class TL>
00742 inline const TG& IndexPair<TG,TL>::global() const {
00743 return global_;
00744 }
00745
00746 template<class TG, class TL>
00747 inline TL& IndexPair<TG,TL>::local() {
00748 return local_;
00749 }
00750
00751 template<class TG, class TL>
00752 inline const TL& IndexPair<TG,TL>::local() const {
00753 return local_;
00754 }
00755
00756 template<class TG, class TL>
00757 inline void IndexPair<TG,TL>::setLocal(int local){
00758 local_=local;
00759 }
00760
00761 template<class TG, class TL, int N>
00762 ParallelIndexSet<TG,TL,N>::ParallelIndexSet()
00763 : state_(GROUND), seqNo_(0)
00764 {}
00765
00766 template<class TG, class TL, int N>
00767 void ParallelIndexSet<TG,TL,N>::beginResize() throw(InvalidIndexSetState)
00768 {
00769
00770
00771 #ifndef NDEBUG
00772 if(state_!=GROUND)
00773 DUNE_THROW(InvalidIndexSetState,
00774 "IndexSet has to be in GROUND state, when "
00775 << "beginResize() is called!");
00776 #endif
00777
00778 state_ = RESIZE;
00779 deletedEntries_ = false;
00780 }
00781
00782 template<class TG, class TL, int N>
00783 inline void ParallelIndexSet<TG,TL,N>::add(const GlobalIndex& global)
00784 throw(InvalidIndexSetState)
00785 {
00786
00787 #ifndef NDEBUG
00788 if(state_ != RESIZE)
00789 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
00790 <<"while in RESIZE state!");
00791 #endif
00792 newIndices_.push_back(IndexPair(global));
00793 }
00794
00795 template<class TG, class TL, int N>
00796 inline void ParallelIndexSet<TG,TL,N>::add(const TG& global, const TL& local)
00797 throw(InvalidIndexSetState)
00798 {
00799
00800 #ifndef NDEBUG
00801 if(state_ != RESIZE)
00802 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
00803 <<"while in RESIZE state!");
00804 #endif
00805 newIndices_.push_back(IndexPair(global,local));
00806 }
00807
00808 template<class TG, class TL, int N>
00809 inline void ParallelIndexSet<TG,TL,N>::markAsDeleted(const iterator& global)
00810 throw(InvalidIndexSetState){
00811
00812 #ifndef NDEBUG
00813 if(state_ != RESIZE)
00814 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
00815 <<"while in RESIZE state!");
00816 #endif
00817 deletedEntries_ = true;
00818
00819 global.markAsDeleted();
00820 }
00821
00822 template<class TG, class TL, int N>
00823 void ParallelIndexSet<TG,TL,N>::endResize() throw(InvalidIndexSetState){
00824
00825 #ifndef NDEBUG
00826 if(state_ != RESIZE)
00827 DUNE_THROW(InvalidIndexSetState, "endResize called while not "
00828 <<"in RESIZE state!");
00829 #endif
00830
00831 std::sort(newIndices_.begin(), newIndices_.end(), IndexSetSortFunctor<TG,TL>());
00832 merge();
00833 seqNo_++;
00834 state_ = GROUND;
00835 }
00836
00837
00838 template<class TG, class TL, int N>
00839 inline void ParallelIndexSet<TG,TL,N>::merge(){
00840 if(localIndices_.size()==0)
00841 {
00842 localIndices_=newIndices_;
00843 newIndices_.clear();
00844 }
00845 else if(newIndices_.size()>0 || deletedEntries_)
00846 {
00847 ArrayList<IndexPair,N> tempPairs;
00848 typedef typename ArrayList<IndexPair,N>::iterator iterator;
00849 typedef typename ArrayList<IndexPair,N>::const_iterator const_iterator;
00850
00851 iterator old=localIndices_.begin();
00852 iterator added=newIndices_.begin();
00853 const const_iterator endold=localIndices_.end();
00854 const const_iterator endadded=newIndices_.end();
00855
00856 while(old != endold && added!= endadded)
00857 {
00858 if(old->local().state()==DELETED) {
00859 old.eraseToHere();
00860 }
00861 else
00862 {
00863 if(old->global() < added->global() ||
00864 (old->global() == added->global()
00865 && LocalIndexComparator<TL>::compare(old->local(),added->local())))
00866 {
00867 tempPairs.push_back(*old);
00868 old.eraseToHere();
00869 continue;
00870 }else
00871 {
00872 tempPairs.push_back(*added);
00873 added.eraseToHere();
00874 }
00875 }
00876 }
00877
00878 while(old != endold)
00879 {
00880 if(old->local().state()!=DELETED) {
00881 tempPairs.push_back(*old);
00882 }
00883 old.eraseToHere();
00884 }
00885
00886 while(added!= endadded)
00887 {
00888 tempPairs.push_back(*added);
00889 added.eraseToHere();
00890 }
00891 localIndices_ = tempPairs;
00892 }
00893 }
00894
00895
00896 template<class TG, class TL, int N>
00897 inline const IndexPair<TG,TL>&
00898 ParallelIndexSet<TG,TL,N>::at(const TG& global) const
00899 {
00900
00901 int low=0, high=localIndices_.size()-1, probe=-1;
00902
00903 while(low<high)
00904 {
00905 probe = (high + low) / 2;
00906 if(global <= localIndices_[probe].global())
00907 high = probe;
00908 else
00909 low = probe+1;
00910 }
00911
00912 if(probe==-1)
00913 DUNE_THROW(RangeError, "No entries!");
00914
00915 if( localIndices_[low].global() != global)
00916 DUNE_THROW(RangeError, "Could not find entry of "<<global);
00917 else
00918 return localIndices_[low];
00919 }
00920
00921 template<class TG, class TL, int N>
00922 inline const IndexPair<TG,TL>&
00923 ParallelIndexSet<TG,TL,N>::operator[](const TG& global) const
00924 {
00925
00926 int low=0, high=localIndices_.size()-1, probe=-1;
00927
00928 while(low<high)
00929 {
00930 probe = (high + low) / 2;
00931 if(global <= localIndices_[probe].global())
00932 high = probe;
00933 else
00934 low = probe+1;
00935 }
00936
00937 return localIndices_[low];
00938 }
00939 template<class TG, class TL, int N>
00940 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::at(const TG& global)
00941 {
00942
00943 int low=0, high=localIndices_.size()-1, probe=-1;
00944
00945 while(low<high)
00946 {
00947 probe = (high + low) / 2;
00948 if(localIndices_[probe].global() >= global)
00949 high = probe;
00950 else
00951 low = probe+1;
00952 }
00953
00954 if(probe==-1)
00955 DUNE_THROW(RangeError, "No entries!");
00956
00957 if( localIndices_[low].global() != global)
00958 DUNE_THROW(RangeError, "Could not find entry of "<<global);
00959 else
00960 return localIndices_[low];
00961 }
00962
00963 template<class TG, class TL, int N>
00964 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::operator[](const TG& global)
00965 {
00966
00967 int low=0, high=localIndices_.size()-1, probe=-1;
00968
00969 while(low<high)
00970 {
00971 probe = (high + low) / 2;
00972 if(localIndices_[probe].global() >= global)
00973 high = probe;
00974 else
00975 low = probe+1;
00976 }
00977
00978 return localIndices_[low];
00979 }
00980 template<class TG, class TL, int N>
00981 inline typename ParallelIndexSet<TG,TL,N>::iterator
00982 ParallelIndexSet<TG,TL,N>::begin()
00983 {
00984 return iterator(*this, localIndices_.begin());
00985 }
00986
00987
00988 template<class TG, class TL, int N>
00989 inline typename ParallelIndexSet<TG,TL,N>::iterator
00990 ParallelIndexSet<TG,TL,N>::end()
00991 {
00992 return iterator(*this,localIndices_.end());
00993 }
00994
00995 template<class TG, class TL, int N>
00996 inline typename ParallelIndexSet<TG,TL,N>::const_iterator
00997 ParallelIndexSet<TG,TL,N>::begin() const
00998 {
00999 return localIndices_.begin();
01000 }
01001
01002
01003 template<class TG, class TL, int N>
01004 inline typename ParallelIndexSet<TG,TL,N>::const_iterator
01005 ParallelIndexSet<TG,TL,N>::end() const
01006 {
01007 return localIndices_.end();
01008 }
01009
01010 template<class TG, class TL, int N>
01011 void ParallelIndexSet<TG,TL,N>::renumberLocal(){
01012 #ifndef NDEBUG
01013 if(state_==RESIZE)
01014 DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in "
01015 <<"GROUND state for renumberLocal()");
01016 #endif
01017
01018 typedef typename ArrayList<IndexPair,N>::iterator iterator;
01019 const const_iterator end_ = end();
01020 uint32_t index=0;
01021
01022 for(iterator pair=begin(); pair!=end_; index++, ++pair)
01023 pair->local()=index;
01024 }
01025
01026 template<class TG, class TL, int N>
01027 inline int ParallelIndexSet<TG,TL,N>::seqNo() const
01028 {
01029 return seqNo_;
01030 }
01031
01032 template<class TG, class TL, int N>
01033 inline size_t ParallelIndexSet<TG,TL,N>::size() const
01034 {
01035 return localIndices_.size();
01036 }
01037
01038 template<class I>
01039 GlobalLookupIndexSet<I>::GlobalLookupIndexSet(const I& indexset,
01040 std::size_t size)
01041 : indexSet_(indexset), size_(size),
01042 indices_(size_, static_cast<const IndexPair*>(0))
01043 {
01044 const_iterator end_ = indexSet_.end();
01045
01046 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) {
01047 assert(pair->local()<size_);
01048 indices_[pair->local()] = &(*pair);
01049 }
01050 }
01051
01052 template<class I>
01053 GlobalLookupIndexSet<I>::GlobalLookupIndexSet(const I& indexset)
01054 : indexSet_(indexset), size_(0)
01055 {
01056 const_iterator end_ = indexSet_.end();
01057 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
01058 size_=std::max(size_,static_cast<std::size_t>(pair->local()));
01059
01060 indices_.resize(++size_, 0);
01061
01062 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
01063 indices_[pair->local()] = &(*pair);
01064 }
01065
01066 template<class I>
01067 GlobalLookupIndexSet<I>::~GlobalLookupIndexSet()
01068 {}
01069
01070 template<class I>
01071 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>*
01072 GlobalLookupIndexSet<I>::pair(const std::size_t& local) const
01073 {
01074 return indices_[local];
01075 }
01076
01077 template<class I>
01078 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>&
01079 GlobalLookupIndexSet<I>::operator[](const GlobalIndex& global) const
01080 {
01081 return indexSet_[global];
01082 }
01083
01084 template<class I>
01085 typename I::const_iterator GlobalLookupIndexSet<I>::begin() const
01086 {
01087 return indexSet_.begin();
01088 }
01089
01090 template<class I>
01091 typename I::const_iterator GlobalLookupIndexSet<I>::end() const
01092 {
01093 return indexSet_.end();
01094 }
01095
01096 template<class I>
01097 inline size_t GlobalLookupIndexSet<I>::size() const
01098 {
01099 return size_;
01100 }
01101
01102 template<class I>
01103 inline int GlobalLookupIndexSet<I>::seqNo() const
01104 {
01105 return indexSet_.seqNo();
01106 }
01107
01108 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
01109 bool operator==(const ParallelIndexSet<TG,TL,N>& idxset,
01110 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
01111 {
01112 if(idxset.size()!=idxset1.size())
01113 return false;
01114 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iter;
01115 typedef typename ParallelIndexSet<TG1,TL1,N1>::const_iterator Iter1;
01116 Iter iter=idxset.begin();
01117 for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) {
01118 if(iter1->global()!=iter->global())
01119 return false;
01120 typedef typename ParallelIndexSet<TG,TL,N>::LocalIndex PI;
01121 const PI& pi=iter->local(), pi1=iter1->local();
01122
01123 if(pi!=pi1)
01124 return false;
01125 }
01126 return true;
01127 }
01128
01129 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
01130 bool operator!=(const ParallelIndexSet<TG,TL,N>& idxset,
01131 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
01132 {
01133 return !(idxset==idxset1);
01134 }
01135
01136
01137 #endif // DOXYGEN
01138
01139 }
01140 #endif