30 #include "TopoManager.h" 
   44   PeList(
int boxX, 
int boxY, 
int boxZ, 
int order, 
int maxX, 
int maxY, 
int maxZ, 
int maxT);
 
   46   PeList(
int _size): size(_size)
 
   49       TheList = 
new int [size+1];
 
   50       sortIdx = 
new int [size+1];
 
   51       for(
int i=0;i<size;i++)
 
   66       TheList = 
new int [size+1];
 
   67       sortIdx = 
new int [size+1];
 
   70       for(
int i=1;i<inlist.size();i++)
 
   72       if(inlist[i]!=TheList[count])
 
   75           TheList[count]=inlist[i];
 
   85       CmiAssert(inlist.size > 0);
 
   88       TheList = 
new int [size+1];
 
   89       sortIdx = 
new int [size+1];
 
   90       for(
int i=0;i<inlist.size;i++)
 
   92       TheList[i]=inlist.TheList[i];
 
   93       sortIdx[i]=inlist.sortIdx[i];
 
   95       current=inlist.current;
 
  104       TheList=
new int [size+1];
 
  105       sortIdx=
new int [size+1];
 
  106       for(
int i=0;i<size;i++)
 
  116       CkAssert(start<a->size);
 
  117       CkAssert(_size<=a->size);
 
  120       TheList=
new int [size+1];
 
  121       sortIdx=
new int [size+1];
 
  122       for(
int i=0;i<size;i++)
 
  124       TheList[i]=a->TheList[a->sortIdx[i+start]];
 
  133       return(size-current<1);
 
  136   inline int count() { 
return(size-current);  }
 
  138   inline void reindex(){
 
  139       for(
int ri=0;ri<size;ri++)
 
  143   inline int exists(
int target)
 
  145       for(
int i=0;i<size;i++)
 
  146     if(TheList[i]==target)
 
  152   void reset(){current=0;} 
 
  157   void resort(){   sortSource(TheList[0]);   }; 
 
  159   void append(
PeList &inlist)
 
  162     int newsize=inlist.size+size;
 
  163     int *newlist= 
new int [newsize+1];
 
  164     int *newIndex= 
new int [newsize+1];
 
  168     newlist[i]=TheList[i];
 
  169     newIndex[i]=sortIdx[i];
 
  171     for(
int j=0; (i< newsize && j<inlist.size) ; i++,j++)
 
  173     newlist[i]=inlist.TheList[j];
 
  183   bool binsearch(
int pe);
 
  185   inline bool find(
int pe)
 
  195       while(!found && i< size)
 
  207   int *pelower_bound(
int pe);
 
  209   inline void mergeOne(
int pe)
 
  215     if(size==1 && pe>TheList[0])
 
  220       int *loc=pelower_bound(pe);
 
  221       int location=loc-TheList;
 
  223       if(location>=size || loc==NULL)
 
  227       else if ((loc>TheList) && (loc[-1] ==pe))
 
  231       else if(TheList[location] ==pe)
 
  236       else if((size>1) &&(location<size-1) && (TheList[location+1]==pe))
 
  244           int *newlist= 
new int [newsize+1];
 
  245           int *newIndex= 
new int [newsize+1];
 
  247         CmiMemcpy(newlist,TheList,location*
sizeof(
int));
 
  248           newlist[location]=pe;
 
  249           CmiMemcpy(&newlist[location+1],loc,(size-(location))*
sizeof(
int));
 
  251           bzero(newIndex,(newsize+1)*
sizeof(
int));
 
  271   inline void appendOne(
int pe)
 
  274     int *newlist= 
new int [newsize+1];
 
  275     int *newIndex= 
new int [newsize+1];
 
  276     CmiMemcpy(&newlist[0],&TheList[0],
sizeof(
int)*size);
 
  277     CmiMemcpy(&newIndex[0],&sortIdx[0],
sizeof(
int)*size);
 
  289   void sortSource(
int srcPe); 
 
  291   PeList &operator=(
PeList &inlist) {TheList=inlist.TheList; sortIdx=inlist.sortIdx;
return *
this;}   
 
  297     int newsize=inlist.size+size;
 
  298     int *newlist= 
new int [newsize];
 
  299     int *newIndex= 
new int [newsize];
 
  303     newlist[i]=TheList[i];
 
  304     newIndex[i]=sortIdx[i];
 
  306     for(
int j=0; (i< newsize &j<inlist.size); i++)
 
  308     newlist[i]=inlist.TheList[j];
 
  321     for(
int i=0; i< inlist.size;i++)
 
  325       if(TheList[j]==inlist.TheList[i])
 
  340   inline void remove(
int pos)
 
  345       for (
int i=pos; i<size-1; i++)
 
  347           TheList[i] = TheList[i+1];
 
  359       if(current>0 && size>0)
 
  368           int newSize= size-current;
 
  369           int *newList = 
new int[newSize+1];
 
  370           int *newSortIdx = 
new int[newSize+1];
 
  371           for(
int i=0; i<newSize;i++)
 
  375           newList[i]=TheList[sortIdx[i+current]];
 
  387   void removeIdx(
int pos)
 
  391       for (
int i=pos; i<size-1; i++)
 
  393           sortIdx[i] = sortIdx[i+1];
 
  400       CkPrintf(
"PeList\n");
 
  401       for(
int j=0; j< size;j++)
 
  402     CkPrintf(
"%d list %d sortidx %d \n",j,TheList[j], sortIdx[j]);
 
  429       CkAbort(
"I hate that we end up in this function");
 
  435             boxX(0), boxY(0), boxZ(0), order(0),
 
  436           maxX(0), maxY(0), maxZ(0), maxT(0), size(_size)
 
  440         PeListFactory(
int bxX, 
int bxY, 
int bxZ, 
int ordr, 
int mxX, 
int mxY, 
int mxZ, 
int mxT):
 
  442             boxX(bxX), boxY(bxY), boxZ(bxZ), order(ordr),
 
  443             maxX(mxX), maxY(mxY), maxZ(mxZ), maxT(mxT)
 
  444         { CkAbort(
"how the fuck did we get here?");}
 
  453                 return new PeList(boxX, boxY, boxZ, order, maxX, maxY, maxZ, maxT);
 
  460         int boxX, boxY, boxZ, order, maxX, maxY, maxZ, maxT, size;
 
PeListFactory(int bxX, int bxY, int bxZ, int ordr, int mxX, int mxY, int mxZ, int mxT)
Use this constructor when you want a PeList created using its boxy constructor. 
Hacky solution to passing a PeList to GSpace(0,0) for use in paircalc mapping without actually having...
int minDist(int source)
return a processor at minumum distance from source 
PeList * operator()() const 
Return an appropriately constructed PeList. 
PeListFactory()
Default constructor.