SortableResizeArray< Elem > Class Template Reference

#include <SortableResizeArray.h>

Inheritance diagram for SortableResizeArray< Elem >:

ResizeArray< Elem > SortedArray< Elem > UniqueSortedArray< Elem > List of all members.

Public Member Functions

 SortableResizeArray (void)
 SortableResizeArray (int size)
 SortableResizeArray (ResizeArray< Elem > &ra)
 SortableResizeArray (SortableResizeArray< Elem > &ra)
 SortableResizeArray (const ResizeArray< Elem > *ra)
 SortableResizeArray (const SortableResizeArray< Elem > *ra)
 SortableResizeArray (Elem **const r, int numElem, int maxElem)
SortableResizeArray< Elem > & operator= (SortableResizeArray< Elem > &sa)
 ~SortableResizeArray (void)
void init (void)
void sort (void)
void sort (int bot, int top)
void uniq (void)
int bsearch (const Elem &elem) const

Detailed Description

template<class Elem>
class SortableResizeArray< Elem >

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 13 of file SortableResizeArray.h.


Constructor & Destructor Documentation

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( void   )  [inline]

Definition at line 49 of file SortableResizeArray.h.

00049 : ResizeArray<Elem>() { init(); }

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( int  size  )  [inline]

Definition at line 51 of file SortableResizeArray.h.

00051 : ResizeArray<Elem>(size) { init(); }

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( ResizeArray< Elem > &  ra  )  [inline]

Definition at line 53 of file SortableResizeArray.h.

00053                                                : 
00054       ResizeArray<Elem>(ra) { init(); }

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( SortableResizeArray< Elem > &  ra  )  [inline]

Definition at line 56 of file SortableResizeArray.h.

00056                                                        :
00057       ResizeArray<Elem>(ra) { init(); }

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( const ResizeArray< Elem > *  ra  )  [inline]

Definition at line 59 of file SortableResizeArray.h.

00059                                                      : 
00060       ResizeArray<Elem>(ra) { init(); }

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( const SortableResizeArray< Elem > *  ra  )  [inline]

Definition at line 62 of file SortableResizeArray.h.

00062                                                              : 
00063       ResizeArray<Elem>(ra) { init(); }

template<class Elem>
SortableResizeArray< Elem >::SortableResizeArray ( Elem **const   r,
int  numElem,
int  maxElem 
) [inline]

Definition at line 65 of file SortableResizeArray.h.

00065                                                                    : 
00066       ResizeArray<Elem>(r,numElem,maxElem) { init(); }

template<class Elem>
SortableResizeArray< Elem >::~SortableResizeArray ( void   )  [inline]

Definition at line 73 of file SortableResizeArray.h.

00073 { }


Member Function Documentation

template<class Elem>
int SortableResizeArray< Elem >::bsearch ( const Elem &  elem  )  const [inline]

Definition at line 106 of file SortableResizeArray.h.

00106                                         {
00107       int test;
00108       int bot = -1;
00109       int top = this->size();
00110       if (this->size() == 0) return (-1);
00111       while (top - bot > 1) {
00112         if ( this->rep.array[test = (bot+top)/2] < elem )
00113           bot = test;
00114         else
00115           top = test;
00116       }
00117       return(top);
00118     }

template<class Elem>
void SortableResizeArray< Elem >::init ( void   )  [inline]

Definition at line 75 of file SortableResizeArray.h.

Referenced by SortableResizeArray< ComputeQMPntChrg >::SortableResizeArray().

00075 { }

template<class Elem>
SortableResizeArray<Elem>& SortableResizeArray< Elem >::operator= ( SortableResizeArray< Elem > &  sa  )  [inline]

Reimplemented in SortedArray< Elem >, SortedArray< int >, SortedArray< idIndxStr >, SortedArray< meMMQMGrp >, SortedArray< LSSSubsDat >, and SortedArray< ComputeQMPntChrg >.

Definition at line 68 of file SortableResizeArray.h.

Referenced by SortedArray< ComputeQMPntChrg >::operator=().

00068                                                                          {
00069       ResizeArray<Elem>::operator=(sa);
00070       return(*this);
00071     }

template<class Elem>
void SortableResizeArray< Elem >::sort ( int  bot,
int  top 
) [inline]

Definition at line 82 of file SortableResizeArray.h.

00082                                 {
00083       int index, size;
00084       if (top > this->rep.size()) top = this->rep.size();
00085       size = top - bot + 1;
00086     
00087       // Make all sub-heaps
00088       for ( index = size/2-1; index > 0; index-- )
00089         siftup(bot, index, size);
00090     
00091       // Take top element of overall heap, and put on top
00092       for ( index = size; index > 1; index-- ) {
00093         siftup(bot, 0, index);
00094         swap(bot, 0, index-1);
00095       }
00096     }

template<class Elem>
void SortableResizeArray< Elem >::sort ( void   )  [inline]

Reimplemented in SortedArray< Elem >, SortedArray< int >, SortedArray< idIndxStr >, SortedArray< meMMQMGrp >, SortedArray< LSSSubsDat >, and SortedArray< ComputeQMPntChrg >.

Definition at line 77 of file SortableResizeArray.h.

Referenced by ComputeNonbondedCUDA::build_exclusions(), ComputePmeMgr::initialize(), initializePmeMap(), SortedArray< ComputeQMPntChrg >::sort(), and SortableResizeArray< ComputeQMPntChrg >::sort().

00077 { sort(0, this->rep.size()-1); }

template<class Elem>
void SortableResizeArray< Elem >::uniq ( void   )  [inline]

Definition at line 123 of file SortableResizeArray.h.

References ResizeArray< Elem >::rep, and ResizeArray< Elem >::size().

Referenced by UniqueSortedArray< Elem >::operator=(), and UniqueSortedArray< Elem >::UniqueSortedArray().

00123                                                 {
00124   if (this->size()) {
00125     int oldIndex=0;
00126     int newIndex=0;
00127     while (++oldIndex < this->size()) {
00128       if ( ! ( this->rep.array[oldIndex] == this->rep.array[newIndex] ) ) {
00129         if (++newIndex != oldIndex)
00130           memcpy((void *)&(this->rep.array[newIndex]),
00131                  (void *)&(this->rep.array[oldIndex]),
00132                  sizeof(Elem));
00133       } else {
00134         this->rep.array[oldIndex].~Elem();
00135       }
00136     }
00137     this->rep.arraySize = ++newIndex;
00138   }
00139 }


The documentation for this class was generated from the following file:
Generated on Wed Nov 22 01:17:23 2017 for NAMD by  doxygen 1.4.7