SortedArray< Elem > Class Template Reference

#include <SortedArray.h>

Inheritance diagram for SortedArray< Elem >:

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

Public Member Functions

 SortedArray (void)
 SortedArray (int s)
 SortedArray (SortedArray< Elem > &sa)
 SortedArray (SortableResizeArray< Elem > &ra)
SortedArray< Elem > & operator= (SortedArray< Elem > &sa)
SortedArray< Elem > & operator= (SortableResizeArray< Elem > &ra)
int load (const Elem &elem)
int add (const Elem &elem)
int del (const Elem &elem)
void sort (void)
int bsearch (const Elem &elem)
int insert (const Elem &elem)
int index (const Elem &elem)
Elem * find (const Elem &elem)

Protected Attributes

int isSorted

Detailed Description

template<class Elem>
class SortedArray< 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 12 of file SortedArray.h.


Constructor & Destructor Documentation

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

Definition at line 20 of file SortedArray.h.

00020                       : SortableResizeArray<Elem>() { 
00021       isSorted = 1;
00022     }

template<class Elem>
SortedArray< Elem >::SortedArray ( int  s  )  [inline]

Definition at line 24 of file SortedArray.h.

00024                        : SortableResizeArray<Elem>(s) { 
00025       isSorted = 1;
00026     }

template<class Elem>
SortedArray< Elem >::SortedArray ( SortedArray< Elem > &  sa  )  [inline]

Definition at line 28 of file SortedArray.h.

00028                                        : SortableResizeArray<Elem>(sa) { 
00029       if(!(isSorted = sa.isSorted)) sort();
00030       isSorted = 1;
00031     }

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

Definition at line 33 of file SortedArray.h.

00033                                                : 
00034         SortableResizeArray<Elem>(ra) {
00035       sort(); isSorted = 1;
00036     }


Member Function Documentation

template<class Elem>
int SortedArray< Elem >::add ( const Elem &  elem  )  [inline]

Reimplemented from ResizeArray< Elem >.

Reimplemented in UniqueSortedArray< Elem >.

Definition at line 55 of file SortedArray.h.

Referenced by ComputeQM::initialize(), ComputeQMMgr::recvForce(), Patch::registerDEdaSumDeposit(), Patch::registerForceDeposit(), Patch::registerPositionPickup(), and Patch::registerPsiSumDeposit().

00055                               {
00056       return(insert(elem));
00057     }

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

Definition at line 70 of file SortedArray.h.

Referenced by SortedArray< ComputeQMPntChrg >::del(), SortedArray< Elem >::find(), SortedArray< ComputeQMPntChrg >::index(), UniqueSortedArray< Elem >::insert(), and SortedArray< Elem >::insert().

00070                                   { 
00071       if (!isSorted) sort();
00072       return (SortableResizeArray<Elem>::bsearch(elem));
00073     }

template<class Elem>
int SortedArray< Elem >::del ( const Elem &  elem  )  [inline]

Definition at line 59 of file SortedArray.h.

Referenced by PatchMgr::sendMovePatches(), PatchMgr::sendOneHomePatch(), Patch::unregisterDEdaSumDeposit(), Patch::unregisterForceDeposit(), Patch::unregisterPositionPickup(), and Patch::unregisterPsiSumDeposit().

00059                                {
00060       int found = bsearch(elem);
00061       if (this->size() != 0 && this->rep[found] == elem) {
00062         return(SortableResizeArray<Elem>::del(found,1));
00063       } else {
00064         return(-1);
00065       }
00066     }

template<class Elem>
Elem * SortedArray< Elem >::find ( const Elem &  elem  )  [inline]

Definition at line 96 of file SortedArray.h.

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

Referenced by ComputeQM::doWork(), PatchMgr::homePatch(), ComputeQM::processFullQM(), ComputeQMMgr::recvPntChrg(), and PatchMgr::~PatchMgr().

00096                                                       {
00097   int found = bsearch(elem);
00098   if ( found < 0 || found == this->size() ) 
00099     return ((Elem *)NULL);
00100   if (this->rep[found] == elem) {
00101     return (&(this->rep[found]));
00102   } else {
00103     return ((Elem *)NULL);
00104   }
00105 }

template<class Elem>
int SortedArray< Elem >::index ( const Elem &  elem  )  [inline]

Definition at line 77 of file SortedArray.h.

Referenced by GlobalMasterIMD::calculate().

00077 { return bsearch(elem); }

template<class Elem>
int SortedArray< Elem >::insert ( const Elem &  elem  )  [inline]

Reimplemented in UniqueSortedArray< Elem >.

Definition at line 83 of file SortedArray.h.

References SortedArray< Elem >::bsearch().

Referenced by SortedArray< ComputeQMPntChrg >::add(), lssDistSort::lssDistSort(), lssDistSort::operator=(), and ComputeQMMgr::procQMRes().

00083                                                      {
00084   int found = bsearch(elem);
00085   if (found == -1) {
00086     return (ResizeArray<Elem>::insert(elem, 0));
00087   }
00088   if (found == (this->size()-1) && this->rep[found] < elem) {
00089     return (ResizeArray<Elem>::insert(elem, this->size()));
00090   } else {
00091     return (ResizeArray<Elem>::insert(elem, found));
00092   }
00093 }

template<class Elem>
int SortedArray< Elem >::load ( const Elem &  elem  )  [inline]

Definition at line 50 of file SortedArray.h.

Referenced by PatchMgr::createHomePatch(), PatchMgr::movePatch(), PatchMgr::preCreateHomePatch(), ComputeQM::processFullQM(), and ComputeQMMgr::recvPntChrg().

00050                                {
00051       isSorted = 0;
00052       return(ResizeArray<Elem>::add(elem));
00053     }

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

Reimplemented from SortableResizeArray< Elem >.

Definition at line 44 of file SortedArray.h.

00044                                                                  {
00045       SortableResizeArray<Elem>::operator=(ra);
00046       sort(); isSorted = 1;
00047       return(*this);
00048     }

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

Reimplemented in UniqueSortedArray< Elem >.

Definition at line 38 of file SortedArray.h.

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

00038                                                           {
00039       SortableResizeArray<Elem>::operator=(sa);
00040       isSorted = sa.isSorted;
00041       return(*this);
00042     }

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

Reimplemented from SortableResizeArray< Elem >.

Definition at line 68 of file SortedArray.h.

Referenced by SortedArray< ComputeQMPntChrg >::bsearch(), lssDistSort::lssDistSort(), SortedArray< ComputeQMPntChrg >::operator=(), lssDistSort::operator=(), ComputeQM::processFullQM(), ComputeQMMgr::procQMRes(), ComputeQMMgr::recvPntChrg(), Patch::registerPositionPickup(), SortedArray< ComputeQMPntChrg >::SortedArray(), and Patch::unregisterPositionPickup().


Member Data Documentation

template<class Elem>
int SortedArray< Elem >::isSorted [protected]

Definition at line 16 of file SortedArray.h.

Referenced by SortedArray< ComputeQMPntChrg >::bsearch(), SortedArray< ComputeQMPntChrg >::load(), SortedArray< ComputeQMPntChrg >::operator=(), SortedArray< ComputeQMPntChrg >::sort(), and SortedArray< ComputeQMPntChrg >::SortedArray().


The documentation for this class was generated from the following file:
Generated on Mon Sep 25 01:17:20 2017 for NAMD by  doxygen 1.4.7