00001 /* @HEADER@ */ 00002 // 00003 /* @HEADER@ */ 00004 00005 #ifndef PLAYA_GENERALIZED_INDEX_HPP 00006 #define PLAYA_GENERALIZED_INDEX_HPP 00007 00008 #include "PlayaDefs.hpp" 00009 #include <deque> 00010 00011 namespace Playa 00012 { 00013 00014 /** 00015 * GeneralizedIndex is a locator for an element in 00016 * vector with arbitrary block structure. Together with the processor's rank 00017 * it can uniquely specify an element in a distributed vector. 00018 * This object is used in operations such as minloc and maxloc on 00019 * arbitrarily-structured vectors. 00020 * 00021 * The implementation is a simple pair of (1) a deque giving the sequence of 00022 * block indices and (2) an integer giving the local offset within the 00023 * lowest-level block. The integer index is local, i.e., relative to the 00024 * block pointed to by the block index. 00025 */ 00026 class GeneralizedIndex 00027 { 00028 public: 00029 /** */ 00030 GeneralizedIndex() : blockIndex_(), localIndex_(-1){} 00031 00032 /** */ 00033 void pushBlockIndex(int b) {blockIndex_.push_back(b);} 00034 00035 /** */ 00036 void popBlockIndex() {blockIndex_.pop_back();} 00037 00038 /** */ 00039 int readBlockIndex() const {return blockIndex_.back();} 00040 00041 /** */ 00042 void setLocalIndex(int i) {localIndex_=i;} 00043 00044 /** */ 00045 int readLocalIndex() const {return localIndex_;} 00046 00047 /** */ 00048 int depth() const {return blockIndex_.size();} 00049 00050 /** */ 00051 const std::deque<int>& blockIndex() const {return blockIndex_;} 00052 00053 00054 private: 00055 std::deque<int> blockIndex_; 00056 int localIndex_; 00057 }; 00058 00059 } 00060 00061 #endif