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)
void 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]
template<class Elem>
int SortedArray< Elem >::bsearch ( const Elem &  elem  )  [inline]
template<class Elem>
void SortedArray< Elem >::del ( const Elem &  elem  )  [inline]
template<class Elem>
Elem * SortedArray< Elem >::find ( const Elem &  elem  )  [inline]

Definition at line 94 of file SortedArray.h.

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

Referenced by ComputeQM::doWork(), GlobalMasterIMD::get_vmd_forces(), PatchMgr::homePatch(), Molecule::prepare_qm(), ComputeQM::processFullQM(), HomePatch::qmSwapAtoms(), ComputeQMMgr::recvPntChrg(), and PatchMgr::~PatchMgr().

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

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

Definition at line 75 of file SortedArray.h.

00075 { return bsearch(elem); }

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

Reimplemented in UniqueSortedArray< Elem >, and UniqueSortedArray< PatchElem >.

Definition at line 81 of file SortedArray.h.

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

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

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

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(), 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]

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 from SortableResizeArray< Elem >.

Reimplemented in UniqueSortedArray< Elem >, and UniqueSortedArray< PatchElem >.

Definition at line 38 of file SortedArray.h.

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

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

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

Member Data Documentation

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

The documentation for this class was generated from the following file:

Generated on 6 Dec 2019 for NAMD by  doxygen 1.6.1